自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(212)
  • 收藏
  • 关注

原创 LeetCode *** 344. Reverse String

题目:Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh". 分析:代码:class Solution {public: string reverseStrin

2016-04-27 22:20:30 297

原创 LeetCode *** 345. Reverse Vowels of a String

题目:Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle". Example 2:Given s = "leetcode", return "leotcede".

2016-04-27 22:19:34 347

原创 LeetCode *** 166. Fraction to Recurring Decimal

题目:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose the repeating part in parenthese

2016-04-27 22:17:11 271

原创 LeetCode *** 29. Divide Two Integers(binary search)

题目:Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 分析:代码:class Solution {public: int divide(int dividend, int divi

2016-04-27 22:16:07 447

原创 LeetCode *** 344. Reverse String

题目:Write a function that takes a string as input and returns the string reversed.Example: Given s = "hello", return "olleh".分析:代码:class Solution {public: string reverseString(

2016-04-27 19:05:29 213

原创 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". 分析:代码:class Solution {public: void reverseWords(s

2016-04-27 17:00:23 272

原创 LeetCode *** 130. Surrounded Regions

题目:Given a 2D board containing 'X' and 'O', capture all regions surrounded by'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O

2016-04-27 15:38:11 211

原创 LeetCode *** 307. Range Sum Query - Mutable (Binary Indexed Trees)

题目:Given an integer array nums, find the sum of the elements between indicesi and j (i ≤ j), inclusive.The update(i, val) function modifies nums by updating the element at indexi to val.Ex

2016-04-27 10:34:32 270

原创 LeetCode *** 91. Decode Ways

题目:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the tot

2016-04-27 10:33:49 218

原创 LeetCode *** 220. Contains Duplicate III (set::lower_bound)

题目:Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] andnums[j] is at most t and the difference between i

2016-04-26 22:54:03 220

原创 LeetCode *** 127. Word Ladder(BFS)

题目:Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWord to endWord, such that: Only one letter can be chan

2016-04-26 20:58:47 325

原创 LeetCode *** 341. Flatten Nested List Iterator(审题审题!!)

题目:Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers or other lists.Example 1:Given the

2016-04-26 19:46:46 325

原创 LeetCode *** 179. Largest Number (sort的使用。。。)

题目: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 formed number is9534330.Note: The result may b

2016-04-26 19:35:22 233

原创 LeetCode *** 211. Add and Search Word - Data structure design(字典树)

题目:Design a data structure that supports the following two operations: void addWord(word)bool search(word)search(word) can search a literal word or a regular expression string containing onl

2016-04-26 09:07:49 279

原创 LeetCode *** 98. Validate Binary Search Tree

题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's ke

2016-04-25 22:22:12 179

原创 LeetCode *** 210. Course Schedule II

题目:There are a total of n courses you have to take, labeled from 0 ton - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed a

2016-04-25 20:34:42 243

原创 LeetCode *** 3. Longest Substring Without Repeating Characters

题目:Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "b

2016-04-25 20:07:48 207

原创 LeetCode *** 71. Simplify Path (getline的使用)

题目:Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"分析:代码:class Solution {public: string

2016-04-25 19:16:30 229

原创 LeetCode *** 304. Range Sum Query 2D - Immutable

题目:Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1,col1) and lower right corner (row2, col2).The above rectangle (with the

2016-04-25 17:06:01 192

原创 LeetCode *** 324. Wiggle Sort II (virtual indexing)

题目:Given an unsorted array nums, reorder it such that nums[0] nums[2] .Example:(1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5, 1, 6].(2) Given nums = [1, 3, 2, 2,

2016-04-25 16:20:59 716

原创 LeetCode *** 152. Maximum Product Subarray

题目:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the lar

2016-04-25 14:58:32 191

原创 LeetCode *** 61. Rotate List

题目:Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.分析:代码:/** * Defin

2016-04-25 10:30:56 213

原创 LeetCode *** 143. Reorder List

题目:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it

2016-04-24 23:17:55 186

原创 LeetCode *** 79. Word Search

题目:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertic

2016-04-24 22:08:58 174

原创 LeetCode *** 43. Multiply Strings 

题目:Given two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Converting the input string to

2016-04-24 20:37:08 182

原创 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"]. (Or

2016-04-24 19:50:00 205

原创 LeetCode *** 150. Evaluate Reverse Polish Notation

题目:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "

2016-04-24 19:14:16 149

原创 LeetCode *** 5. Longest Palindromic Substring

题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length ofS is 1000, and there exists one unique longest palindromic substring.分析:

2016-04-24 18:55:14 177

原创 LeetCode *** 221. Maximal Square

题目:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matrix: 1 0 1 0 01 0 1 1 11 1 1 1 11 0 0

2016-04-24 18:04:12 183

原创 LeetCode *** 18. 4Sum (Two Pointers)

题目:Given an array S of n integers, are there elements a,b, c, and d in S such that a + b +c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:El

2016-04-24 11:34:23 197

原创 LeetCode *** 15. 3Sum (Two Pointers )

题目: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:Elements in a triplet (a

2016-04-24 11:26:10 226

原创 LeetCode *** 332. 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 fromJFK.

2016-04-24 09:54:19 223

原创 LeetCode *** 133. Clone Graph

题目:Clone an undirected graph. Each node in the graph contains a label and a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniquely. We use # as a separator for

2016-04-23 23:20:46 157

原创 LeetCode *** 322. 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

2016-04-23 19:15:01 171

原创 LeetCode *** 222. Count Complete Tree Nodes

题目:Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely

2016-04-23 18:08:34 248

原创 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""23

2016-04-23 17:09:40 184

原创 LeetCode *** 139. Word Break

题目:Given a string s and a dictionary of words dict, determine ifs can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = [

2016-04-23 16:05:26 217

原创 LeetCode *** 208. Implement Trie (Prefix Tree) (给指针数组赋空间)

题目:Implement a trie with insert, search, and startsWith methods.分析:在给指针数组分空间的时候出错了几次。代码:class TrieNode {public: TrieNode *next[26]; bool isStr = false; // Initialize your data st

2016-04-23 15:13:50 256

原创 LeetCode *** 306. Additive Number

题目:Additive number is a string whose digits can form additive sequence.A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number i

2016-04-23 14:47:30 198

原创 LeetCode *** 187. Repeated DNA Sequences

题目:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.

2016-04-23 13:34:21 241

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除