- 博客(32)
- 资源 (1)
- 收藏
- 关注
原创 [leetcode] 286. Walls and Gates 解题报告
题目链接:https://leetcode.com/problems/walls-and-gates/You are given a m x n 2D grid initialized with these three possible values.-1 - A wall or an obstacle.0 - A gate.INF - Infinity means an em
2016-02-29 07:40:33 2823
原创 [leetcode] 200. Number of Islands 解题报告
题目链接:https://leetcode.com/problems/number-of-islands/Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connect
2016-02-29 07:01:33 742
原创 [leetcode] 249. Group Shifted Strings 解题报告
题目链接:https://leetcode.com/problems/group-shifted-strings/Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which f
2016-02-29 05:35:37 1553
原创 [leetcode] 49. Group Anagrams 解题报告
题目链接:https://leetcode.com/problems/anagrams/Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","t
2016-02-29 05:02:32 2280
原创 [leetcode] 253. Meeting Rooms II 解题报告
题目链接:https://leetcode.com/problems/meeting-rooms-ii/Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of confe
2016-02-29 04:37:13 6410
原创 [leetcode] 69. Sqrt(x) 解题报告
题目链接:https://leetcode.com/problems/sqrtx/Implement int sqrt(int x).Compute and return the square root of x.思路:二分查找,每次看中间的数平方是不是和当前数相等.代码如下:class Solution {public: int mySqrt(int
2016-02-28 17:06:50 495
原创 [leetcode] 314. Binary Tree Vertical Order Traversal 解题报告
题目链接:https://leetcode.com/problems/binary-tree-vertical-order-traversal/Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).
2016-02-28 16:51:34 2796
原创 [leetcode] 252. Meeting Rooms 解题报告
题目链接:https://leetcode.com/problems/meeting-rooms/Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend
2016-02-26 16:03:10 3367
原创 [leetcode] 266. Palindrome Permutation 解题报告
题目链接:https://leetcode.com/problems/palindrome-permutation/Given a string, determine if a permutation of the string could form a palindrome.For example,"code" -> False, "aab" -> True, "ca
2016-02-26 14:47:52 1782
原创 [leetcode] 210. Course Schedule II 解题报告
题目链接:https://leetcode.com/problems/course-schedule-ii/There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take cour
2016-02-26 14:22:04 1397
原创 [leetcode] 207. Course Schedule 解题报告
题目链接:https://leetcode.com/problems/course-schedule/There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course
2016-02-26 14:10:16 1818
原创 [leetcode] 273. Integer to English Words 解题报告
题目链接:https://leetcode.com/problems/integer-to-english-words/Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example,
2016-02-25 03:49:10 1163
原创 [leetcode] 128. Longest Consecutive Sequence 解题报告
题目链接:https://leetcode.com/problems/longest-consecutive-sequence/Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4,
2016-02-25 02:13:43 3778
原创 [leetcode] 190. Reverse Bits 解题报告
题目链接:https://leetcode.com/problems/reverse-bits/Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100)
2016-02-25 00:06:21 653
原创 [leetcode] One Edit Distance 解题报告
题目链接:Given two strings S and T, determine if they are both one edit distance apart.Hint:1. If | n – m | is greater than 1, we know immediately both are not one-edit distance apart.2.
2016-02-24 14:20:15 784
原创 [leetcode] 43. Multiply Strings 解题报告
题目链接:https://leetcode.com/problems/multiply-strings/Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and
2016-02-21 15:03:17 548
原创 [leetcode] 50. Pow(x, n) 解题报告
题目链接:https://leetcode.com/problems/powx-n/Implement pow(x, n).思路:使用二分来分治计算,要注意一些特殊情况:奇数和偶数,n=0,为负等情况代码如下:class Solution {public: double myPow(double x, int n) { if(n == 1) r
2016-02-21 12:40:47 867
原创 [leetcode] 47. Permutations II 解题报告
题目链接:https://leetcode.com/problems/permutations-ii/Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the followi
2016-02-21 11:42:58 455
原创 [leetcode] 215. Kth Largest Element in an Array 解题报告
题目链接:https://leetcode.com/problems/kth-largest-element-in-an-array/Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth dis
2016-02-21 07:29:34 2459
原创 [leetcode] 29. Divide Two Integers 解题报告
题目链接:https://leetcode.com/problems/divide-two-integers/Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.思路:一个数除以被除数的本质就是包含多少个
2016-02-21 06:37:53 1847
原创 [leetcode] 313. Super Ugly Number 解题报告
题目链接:https://leetcode.com/problems/super-ugly-number/Write a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime
2016-02-20 05:44:38 1979
原创 [leetcode] 322. Coin Change 解题报告
题目链接:https://leetcode.com/problems/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
2016-02-20 04:32:28 1091
原创 [leetcode] 328. Odd Even Linked List 解题报告
题目链接:https://leetcode.com/problems/odd-even-linked-list/Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number
2016-02-20 00:14:03 608
原创 [leetcode] 329. Longest Increasing Path in a Matrix 解题报告
题目链接:https://leetcode.com/problems/longest-increasing-path-in-a-matrix/Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four dir
2016-02-19 23:40:18 842
原创 [leetcode] 334. Increasing Triplet Subsequence 解题报告
题目链接:https://leetcode.com/problems/increasing-triplet-subsequence/Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the functio
2016-02-19 13:14:48 1833
原创 [leetcode] 189. Rotate Array 解题报告
题目链接:https://leetcode.com/problems/rotate-array/Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,
2016-02-13 18:30:57 589
原创 [leetcode] 204. Count Primes 解题报告
题目链接:https://leetcode.com/problems/count-primes/Description:Count the number of prime numbers less than a non-negative number, n.思路:筛选法求素数代码如下:class Solution {public:bool flag[2000
2016-02-13 18:05:57 755
原创 [leetcode] 205. Isomorphic Strings 解题报告
题目链接:https://leetcode.com/problems/isomorphic-strings/Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.
2016-02-13 17:39:30 793
原创 [leetcode] 7. Reverse Integer 解题报告
题目链接:https://leetcode.com/problems/reverse-integer/Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321思路:注意溢出情况处理class Solution {public: in
2016-02-13 16:54:59 442
原创 [leetcode] 56. Merge Intervals 解题报告
题目链接:Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].思路:还是比较简单的思路,不过要注意区间首先要排序.代码如下:/*
2016-02-13 13:29:35 660
原创 [leetcode] 57. Insert Interval 解题报告
题目链接:https://leetcode.com/problems/insert-interval/Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals w
2016-02-13 12:59:33 659
原创 [leetcode] 179. Largest Number 解题报告
题目链接:https://leetcode.com/problems/largest-number/Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest
2016-02-04 07:03:30 848
qt3扫雷代码
2013-11-15
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人