- 博客(20)
- 收藏
- 关注
原创 [leetcode] 151. Reverse Words in a String
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C programmers: Try to solve it in-place in
2016-07-29 16:57:58 464
原创 [leetcode] 292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the
2016-07-28 17:15:56 314
原创 [leetcode] 118. Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]这道题是生成杨辉三角的前n
2016-07-27 16:08:14 350
原创 [leetcode] 72. Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:
2016-07-26 16:48:20 340
原创 [leetcode] 376. Wiggle Subsequence
A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either pos
2016-07-25 17:32:23 2084
原创 [leetcode] 13. Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.这道题是将罗马数字转化为阿拉伯数字,题目难度为Easy。解题的关键依然在罗马数字的规律上,题目和第12题相关,不了解罗马数字规律的同学可以先看下第1
2016-07-22 11:33:05 290
原创 [leetcode] 331. Verify Preorder Serialization of a Binary Tree
One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #.
2016-07-21 16:45:51 377
原创 [leetcode] 12. Integer to Roman
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.这道题是将阿拉伯数字转化为罗马数字,题目难度为Medium。题目的关键在罗马数字的规律上,由于对罗马数字的认识仅限于钟表上的几个数字,所以查了下罗马
2016-07-20 18:58:16 470
原创 [leetcode] 295. Find Median from Data Stream
Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4] , the median
2016-07-19 16:26:22 703
原创 [leetcode] 93. Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order
2016-07-15 17:23:45 275
原创 [leetcode] 60. Permutation Sequence
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""312
2016-07-14 17:10:27 311
原创 [leetcode] 374. Guess Number Higher or Lower
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 is h
2016-07-13 16:36:46 371
原创 [leetcode] 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3
2016-07-13 16:06:07 412
原创 [leetcode] 104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.这道题是求二叉树深度,题目难度为Easy。可
2016-07-12 16:13:56 329
原创 [leetcode] 230. Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.Follow up:What if the
2016-07-11 16:25:33 371
原创 [leetcode] 373. Find K Pairs with Smallest Sums
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.Define a pair (u,v) which consists of one element from the first array and one element from the second a
2016-07-08 17:11:35 1664
原创 [leetcode] 363. Max Sum of Rectangle No Larger Than K
Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k.Example:Given matrix = [ [1, 0, 1], [0, -2, 3]]k
2016-07-07 17:42:33 1213
原创 [leetcode] 371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.这道题是计算两个整数之和,题目难度为Easy。不能使用+和-运算,所以只能通过位操作来计算。通
2016-07-06 16:19:16 363
原创 [leetcode] 368. Largest Divisible Subset
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.If there are multiple solution
2016-07-04 16:02:27 433
原创 [leetcode] 100. Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.这道
2016-07-01 11:34:16 250
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人