Leetcode
快乐的小鸟-ZJU
这个作者很懒,什么都没留下…
展开
-
[LeetCode]Generalized Abbreviation
class SolutionTest {public: vector res; vector generateAbbreviations(string word) { if(word.size()==0) return res; dfs(word,"",0); return res; } void dfs(string& s,string cur,int start) {原创 2016-03-22 13:22:07 · 278 阅读 · 0 评论 -
[Leetcode 399]Evaluate Division
[Leetcode 399]Evaluate Division原创 2016-10-03 20:27:39 · 516 阅读 · 0 评论 -
[Leetcode]386. Lexicographical Numbers
[Leetcode]386. Lexicographical Numbers原创 2016-10-04 07:47:44 · 428 阅读 · 0 评论 -
[Leetcode 375] Guess Number Higher or Lower II
[Leetcode 375] Guess Number Higher or Lower II原创 2016-10-04 16:07:21 · 460 阅读 · 0 评论 -
[Leetcode]376. Wiggle Subsequence
[Leetcode]376. Wiggle Subsequence原创 2016-10-04 16:58:36 · 360 阅读 · 0 评论 -
[Leetcode]388. Longest Absolute File Path
[Leetcode]388. Longest Absolute File Path原创 2016-10-04 19:26:33 · 387 阅读 · 0 评论 -
[Leetcode]330. Patching Array
[Leetcode]330. Patching Array原创 2016-10-04 21:30:56 · 283 阅读 · 0 评论 -
Leetcode 269. Alien Dictionary
Leetcode 269. Alien Dictionary原创 2016-10-05 18:24:29 · 361 阅读 · 0 评论 -
Leetcode 286. Walls and Gates (Google面试题 BFS,记忆化搜索)
Leetcode 286. Walls and Gates (Google面试题 BFS,记忆化搜索)原创 2016-10-05 22:14:49 · 1297 阅读 · 0 评论 -
Leetcode 246. Strobogrammatic Number
A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Write a function to determine if a number is strobogrammatic. The number is represented as a原创 2016-10-06 12:22:39 · 306 阅读 · 0 评论 -
Leetcode 317. Shortest Distance from All Buildings(多次BFS)
Leetcode 317. Shortest Distance from All Buildings原创 2016-10-06 12:59:44 · 482 阅读 · 0 评论 -
Leetcode 276. Paint Fence (经典DP)
Leetcode 276. Paint Fence (经典DP)原创 2016-10-06 13:31:50 · 456 阅读 · 0 评论 -
Leetcode 265. Paint House II
Leetcode 265. Paint House II原创 2016-10-06 14:11:14 · 459 阅读 · 0 评论 -
Leetcode 247. Strobogrammatic Number II (数学,递归)
Leetcode 247. Strobogrammatic Number II (数学,递归)原创 2016-10-06 15:29:19 · 447 阅读 · 0 评论 -
Leetcode 294. Flip Game II (回溯,记忆化)
Leetcode 294. Flip Game II (回溯,记忆化)原创 2016-10-06 22:19:25 · 716 阅读 · 0 评论 -
[Leetcode 411]Minimum Unique Word Abbreviation
[Leetcode 411]Minimum Unique Word Abbreviation原创 2016-10-03 19:57:48 · 2601 阅读 · 1 评论 -
Leetcode 254. Factor Combinations 找一个数的所有因子(Backtracking)
Leetcode 254. Factor Combinations 找一个数的所有因子(Backtracking)原创 2016-10-09 21:16:15 · 1234 阅读 · 0 评论 -
[Leetcode]Binary Tree Vertical Order Traversal
class Solution {public: vector> res; map> Map; vector> verticalOrder(TreeNode* root) { if(root==NULL) return res; dfs(root,0); map>::iterator it; for(it=Map.begin();it!=Map.end();it++) {原创 2016-03-22 15:03:22 · 237 阅读 · 0 评论 -
[Leetcode]Binary Tree Longest Consecutive Sequence
Binary Tree Longest Consecutive SequenceTotal Accepted: 437 Total Submissions: 1351 Difficulty: MediumGiven a binary tree, find the length of the longest consecutive sequence p原创 2016-03-22 16:04:02 · 615 阅读 · 0 评论 -
[LeetCode294] Flip Game II
You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip twoconsecutive "++" into "--". The g原创 2016-03-22 16:31:19 · 302 阅读 · 0 评论 -
[Lintcode]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".Have you met this question in a real interview? YesC原创 2016-03-22 17:05:18 · 328 阅读 · 0 评论 -
[LeetCode] Reverse Words in a String II(in-place 算法)
Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters.The input string does not contain leading or trailing spaces and the words are always原创 2016-03-22 17:16:13 · 637 阅读 · 0 评论 -
[Leetcode 286]: Walls and Gates
Walls and GatesTotal Accepted: 411 Total Submissions: 1365 Difficulty: MediumYou are given a m x n 2D grid initialized with these three possible values.-1 - A wall or an ob原创 2016-03-23 10:03:57 · 456 阅读 · 0 评论 -
leetcode 280: Wiggle Sort
Wiggle SortTotal Accepted: 1291 Total Submissions: 3008 Difficulty: MediumGiven an unsorted array nums, reorder it in-place such that nums[0] = nums[2] .For example, given转载 2016-03-23 11:00:01 · 309 阅读 · 0 评论 -
[Leetcode 256]Paint House
题目链接:http://www.lintcode.com/en/problem/paint-house/There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a原创 2016-03-23 17:07:57 · 348 阅读 · 0 评论 -
[Leetcode 265]Paint House II
题目链接: http://www.lintcode.com/en/problem/paint-house-ii/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 colo原创 2016-03-23 17:32:37 · 1031 阅读 · 0 评论 -
[LeetCode] Shortest Word Distance I & II & III (好题)
转自: http://www.cnblogs.com/easonliu/p/4784826.htmlShortest Word DistanceGiven a list of words and two words word1 and word2, return the shortest distance between these two words in the l转载 2016-03-23 19:23:59 · 779 阅读 · 0 评论 -
[LeetCode 265] Count Univalue Subtrees
题目:Given a binary tree, count the number of uni-value subtrees.A Uni-value subtree means all nodes of the subtree have the same value.For example:Given binary tree,原创 2016-03-23 20:03:42 · 555 阅读 · 0 评论 -
[LeetCode 253] Meeting Rooms II
Given an array of meeting time intervals consisting of start and end times [[s1,e1], [s2,e2],...] (si For example,Given [[0, 30],[5, 10],[15, 20]],return 2.线段最大重叠数class Solution {原创 2016-03-23 21:30:16 · 734 阅读 · 0 评论 -
[Facebook 面试题]Meeting roomII 变形题
facebook 二面题目:interval [startTime, stoptime) ----integral time stamps给这样的一串区间 I1, I2......In 找出 一个 time stamp 出现在interval的次数最多。startTime example: [1,3), [2, 7), [4, 8), [5, 9)原创 2016-03-24 14:39:39 · 1075 阅读 · 0 评论 -
[Leetcode]358. Rearrange String k Distance Apart (贪心,窗口,堆,字符)
[Leetcode]358. Rearrange String k Distance Apart (贪心,窗口,堆,字符)原创 2016-07-22 16:31:31 · 1620 阅读 · 0 评论 -
Leetcode 68. Text Justification (Airbnb面试题,字符串处理,边界条件)
Leetcode 68. Text Justification (Airbnb面试题,字符串处理,边界条件)原创 2016-10-08 11:07:34 · 1978 阅读 · 0 评论