c/c++
robertsjtu
这个作者很懒,什么都没留下…
展开
-
House Robber III
he thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After a tour,转载 2016-03-21 22:27:40 · 205 阅读 · 0 评论 -
Reconstruct Itinerary
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the转载 2016-09-06 16:55:03 · 247 阅读 · 0 评论 -
Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray原创 2016-09-05 21:24:45 · 157 阅读 · 0 评论 -
Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, given s = “leetcode”, dict = [“leet”, “co原创 2016-09-05 17:05:01 · 171 阅读 · 0 评论 -
Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x.解: 2分搜索的应用,题目很简单,但要注意overflow的坑class Solution {public: int mySqrt(int x) { int l=0; int r=x; while(l<r)原创 2016-09-04 19:12:43 · 163 阅读 · 0 评论 -
Coin Change
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money c原创 2016-09-04 17:45:31 · 135 阅读 · 0 评论 -
Maximal Square
Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.For example, given the following matrix:1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Ret原创 2016-09-03 22:47:14 · 166 阅读 · 0 评论 -
Minimum Height Trees
For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minim转载 2016-09-03 20:32:49 · 247 阅读 · 0 评论 -
3sum
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 zero.Note: The solution set must not contain duplic原创 2016-09-02 17:48:59 · 179 阅读 · 0 评论 -
Kth Smallest Element in a Sorted Matrix
Note that it is the kth smallest element in the sorted order, not the kth distinct element.Example:matrix = [ [ 1, 5, 9], [10, 11, 13], [12, 13, 15] ], k = 8,return 13. Note: You may原创 2016-08-07 21:28:00 · 282 阅读 · 5 评论 -
Guess Number Higher or Lower II
We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I’ll tell you whether the number I picked is highe转载 2016-09-25 10:58:29 · 270 阅读 · 0 评论