摘要:
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of 阅读全文
摘要:
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contai 阅读全文
摘要:
思路: 这道题因为只有一对,所以可以用hashmap,需要注意的是,数字可能有重复, eg.[1,2,2,3,4] target = 4. 所以最好的办法就是把剩下的放进去。 这样如果有重复,没关系,把现在的index和已经放进去的index返回即可。 阅读全文
摘要:
Write a program to swap odd and even bits in an integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are s 阅读全文
摘要:
There is a building of n floors. If an egg drops from the k th floor or above, it will break. If it's dropped from any floor below, it will not break. 阅读全文
摘要:
A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but i 阅读全文
摘要:
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
摘要:
Given a knight in a chessboard n * m (a binary matrix with 0 as empty and 1 as barrier). the knight initialze position is (0, 0) and he wants to reach 阅读全文
摘要:
76. Longest Increasing Subsequence 116. Jump Game 603. Largest Divisible Subset 611. Knight Shortest Path 630. Knight Shortest Path II 116. Jump Game 阅读全文
摘要:
This question is standard level BSF. From this question, we can see the best time to mark a node is the time when it is added to a queue. 阅读全文