- 博客(16)
- 收藏
- 关注
原创 [leetcode][单调性] Next Permutation
题目:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest
2015-08-25 15:55:04 383
原创 [leetcode][贪心] Candy
题目:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at
2015-08-24 12:02:48 535
原创 [leetcode][math] Missing Number
题目:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3] return 2.Note:Your algori
2015-08-24 10:48:48 405
原创 [leetcode][string] Longest Palindromic Substring
题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.Manacher算法(
2015-08-19 16:28:18 302
原创 [leetcode][dp] Ugly Number II
Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first
2015-08-19 11:23:19 421
原创 [leetcode][math] Ugly Number
题目:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is no
2015-08-19 11:21:42 484
原创 [leetcode] 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 connecting adjacent lands horizontally or vertically. You
2015-08-18 18:43:59 289
原创 内存泄露检测
1.vs2013(1)#define CRTDBG_MAP_ALLOC(2)#if DEBUG#ifdef _DEBUG#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)注:用于定位哪一行发生内存泄漏(3)在入口函数的结束处添加 _CrtDumpMemoryLeaks();(4)F5运行,即可在输出窗口看到内存泄
2015-08-18 14:40:59 394
原创 [leetcode][trie] Implement Trie (Prefix Tree)
题目:Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.class TrieNode {public: // Initialize your da
2015-08-18 13:56:07 336
原创 [leetcode][two pointers] Minimum Size Subarray Sum
题目:Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, given the a
2015-08-18 10:00:27 336
原创 [leetcode][位运算] Single Number III
题目:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:
2015-08-17 17:42:47 943
原创 [leetcode][deque] Sliding Window Maximum
题目:Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding
2015-08-17 17:15:45 379
原创 [leetcode][stack] Implement Queue using Stacks
题目:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front eleme
2015-08-17 09:21:54 357
原创 [leetcode][math] Add Digits
题目:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2
2015-08-16 14:31:55 819
原创 [leetcode][tree] Binary Tree Paths
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]/**
2015-08-16 13:34:50 970 2
原创 [leetcode][dfs] Different Ways to Add Parentheses
题目:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are+, - and *.Examp
2015-08-15 15:37:41 351
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人