随笔分类 - Level 2
摘要:Determine the number of bits required to flip if you want to convert integer n to integer m. Notice Both n and m are 32-bit integers. Determine the nu
阅读全文
摘要:There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it cost
阅读全文
摘要:Given an integer array (index from 0 to n-1, where n is the size of this array), and an query list. Each query has two integers [start, end]. For each
阅读全文
摘要:Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endp
阅读全文
摘要:Implement pow(x, n). Notice You don't need to care about the precision of your answer, it's acceptable if the expected answer and your answer 's diffe
阅读全文
摘要:Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the u
阅读全文
摘要:Given a binary tree, return all root-to-leaf paths. Example Given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: [ "1->2->5", "1
阅读全文
摘要:Write an algorithm to determine if a number is happy. A happy number is a number defined by the following process: Starting with any positive integer,
阅读全文
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example Given n = 12, retu
阅读全文
摘要:Given two binary strings, return their sum (also a binary string). Example a = 11 b = 1 Return 100 分析: 这个和10进制加法一样。 total = a + b + carryover; digit =
阅读全文
摘要:Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is a
阅读全文
摘要:Write a method to replace all spaces in a string with %20. The string is given in a characters array, you can assume it has enough space for replaceme
阅读全文
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. Notice Bonus point if you
阅读全文
摘要:Given an integer array, heapify it into a min-heap array. For a heap array A, A[0] is the root of heap, and for each A[i], A[i * 2 + 1] is the left ch
阅读全文
摘要:You have two every large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of
阅读全文
摘要:Given an unsorted integer array, find the first missing positive integer. Example Given [1,2,0] return 3,and [3,4,-1,1] return 2. 分析: 我们只需要把1到A.length
阅读全文
摘要:There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. Yo
阅读全文
摘要:Segment Tree Query I For an integer array (index from 0 to n-1, where n is the size of this array), in the corresponding SegmentTree, each node stores
阅读全文
摘要:Segment Tree Build I The structure of Segment Tree is a binary tree which each node has two attributes start and end denote an segment / interval. sta
阅读全文
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l
阅读全文

浙公网安备 33010602011771号