Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example 1: Example 2: Follow up: Could you ...
Given an integer, write a function to determine if it is a power of two. Example : Example : Example : 这道题让我们判断一个数是否为 的次方数,而且要求时间和空间复杂度都为常数,那么对于这种玩数字的题,我们应该首先考虑位操作 Bit Operation。在LeetCode中,位操作的题有很多,比 ...
2015-07-06 04:40 5 16654 推荐指数:
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example 1: Example 2: Follow up: Could you ...
Given an integer, write a function to determine if it is a power of three. Example 1: Example 2: Example 3: Example 4: Follow up ...
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would ...
题目描述 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。 你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用。 示例: 给定 nums = [2, 7, 11, 15] ...
「ALBB面试题」 【题目】 如何判断一个数是否为2的n次方 【题目分析】 看到这种题,相信大家第一反应就是循环除2,这样做肯定是可以得出结果的;但是这种做法无疑大大增加了计算机的运行时间,一个非常大的数字可能会让计算机内存溢出,有没有更好的解决方式呢?有!如果你对数字2敏感,那么一定 ...
题目要求 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each ...
题目描述: 给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 如果,我们将这两个数相加起来,则会返回一个新的链 ...
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example 1: Example ...