2016-06-16 YongHao Hu
C++
231. Power of Two Question Given an integer, write a function to determine if it is a power of two. Solution Approach #1 (count the number of 1) [Accepted] Algorithm Integer is a power of two means only one bit of n is '1', for example, 100 is 2^2=4 while 110 is 2^2+2^1=6. 继续阅读 »
2016-06-06 craneyuan
Question Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. Note: Given n will always be valid. Try to do this in one pass. 解说 这道题的意思是,如何反向删 继续阅读 »
2016-05-06 craneyuan
Question 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 have exactly one solution. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]. UPDATE (2016/2/13): The return forma 继续阅读 »