随笔分类 - LintCode
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl
阅读全文
摘要:Implement a trie with insert, search, and startsWith methods. Notice You may assume that all inputs are consist of lowercase letters a-z. Implement a
阅读全文
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target va
阅读全文
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element.
阅读全文
摘要:Find the last position of a target number in a sorted array. Return -1 if target does not exist. Find the last position of a target number in a sorted
阅读全文
摘要:Given some points and a point origin in two dimensional space, find k points out of the some points which are nearest to origin.Return these points so
阅读全文
摘要:Given a target number, a non-negative integer k and an integer array A sorted in ascending order, find the k closest numbers to target in A, sorted in
阅读全文
摘要:Given a target number and an integer array A sorted in ascending order, find the index i in A such that A[i] is closest to the given target. Return -1
阅读全文
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Given a positive integer n
阅读全文
摘要:Given a knight in a chessboard n * m (a binary matrix with 0 as empty and 1 as barrier). the knight initial position is (0, 0) and he wants to reach p
阅读全文
摘要:Given a knight in a chessboard (a binary matrix with 0 as empty and 1 as barrier) with a sourceposition, find the shortest path to a destination posit
阅读全文
摘要:Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Given a binary tree, find the maximum path sum. Th
阅读全文
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. Bonus point if you are ab
阅读全文
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
阅读全文
摘要:Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space
阅读全文
摘要:A robot is located at the top-left corner of a m x n grid. The robot can only move either down or right at any point in time. The robot is trying to r
阅读全文
摘要:Determine the number of bits required to flip if you want to convert integer n to integer m. Both n and m are 32-bit integers. Determine the number of
阅读全文
摘要:Using O(1) time to check whether an integer n is a power of 2. Using O(1) time to check whether an integer n is a power of 2. Using O(1) time to check
阅读全文
摘要:Count how many 1 in binary representation of a 32-bit integer. Count how many 1 in binary representation of a 32-bit integer. Count how many 1 in bina
阅读全文
摘要:Bit Rotation -—— A rotation (or circular shift) is an operation similar to shift except that the bits that fall off at one end are put back to the oth
阅读全文