- 博客(30)
- 资源 (3)
- 收藏
- 关注
原创 LeetCode131——Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab", Return [ ["aa","b
2015-02-28 15:36:07 1264
原创 LeetCode15——3Sum
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,b,c) must
2015-02-28 14:24:09 1087
原创 LeetCode133——Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization: Nodes are labeled uniquely.We use # as a separator for each
2015-02-28 11:39:55 1258
原创 LeetCode134——Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to it
2015-02-27 16:28:35 1021
原创 LeetCode2——Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a li
2015-02-27 11:24:13 955
原创 LeetCode136——Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using e
2015-02-27 10:40:39 1384
原创 LeetCode137——Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without u
2015-02-26 18:15:42 2038
原创 LeetCode173——Binary Search Tree Iterator
终于进入了中等难度的题目了。貌似leetcode不停地加题量,要做完正的是不那么容易啊。新年开工,小伙伴们都在晒红包,深圳这边 上班第一天一般都有发红包,不知道其他地方的是不是也这样。到目前为止,做了40题了,不得不感慨,算法有待提高。大学真是白过了,人生那么美好的四年白过了,这是多么的悲哀。 现在想想,一个人要想在大学过得有意义,对以后的人生打下坚实的基础,那么最迟在大学一年之后,一定要
2015-02-26 17:08:41 1341
原创 LeetCode189——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,3,4].Note: Try to come up as many solutions as you c
2015-02-26 09:54:19 13051 9
原创 回溯法求解N皇后问题
问题描述:在n*n格的棋盘上放置彼此不受攻击的n个皇后(按照国际象棋的规则),即任意两个皇后不能处在同一行或同一列或同一斜线上。实现:/* *回溯法,N皇后问题 *author: booirror@163.com */#include <iostream>#include <vector>#include <cmath>using namespace std;struct Point{
2015-02-12 15:45:03 2079
原创 LeetCode38——Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one 2
2015-02-11 18:43:12 1448
原创 LeetCode58——Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is d
2015-02-11 17:32:19 1420
原创 LeetCode21——Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.难度系数:容易实现ListNode *mergeTwoLists(ListNode *l1
2015-02-11 17:19:57 1296
原创 LeetCode67——Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".难度系数:容易实现string addBinary(string a, string b){ string sum; int
2015-02-11 16:37:51 1055
原创 LeetCode36——Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially filled sudo
2015-02-11 15:32:21 1247
原创 LeetCode66——Plus One
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.难度系数:容易实现v
2015-02-11 15:30:34 974
原创 LeetCode70——Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?难度系数:容易实现int climb
2015-02-11 15:28:56 1603
原创 LeetCode28——Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The signature of the function had been updat
2015-02-11 15:23:41 1104
原创 LeetCode27——Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.难
2015-02-11 15:20:33 693
原创 LeetCode83——Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.难度系数:容易实现ListN
2015-02-11 15:19:02 819
原创 LeetCode26——Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with
2015-02-11 15:16:43 1054
原创 LeetCode100——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.难度系数:容
2015-02-05 15:35:08 700
原创 LeetCode101——Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the follow
2015-02-05 15:33:35 982
原创 LeetCode102——Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20
2015-02-05 15:31:46 1097
原创 LeetCode104——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.难度系数:容易实现int maxDepth(Tr
2015-02-05 15:29:44 1966
原创 LeetCode107——Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7}
2015-02-05 15:28:15 1165
原创 LeetCode110——Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe
2015-02-05 15:26:00 1563
原创 LeetCode111——Given a binary tree, find its minimum depth.
The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.之后发的文章就不翻译了,因为一般读这个文章的人都是刷LeetCode的人,读题目应该不成问题,我就不做多余的翻译了。难度系数:容易实现i
2015-02-05 15:23:26 2011
原创 LeetCode19——Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the
2015-02-05 15:07:55 1582
原创 LeetCode118——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]]题目大意给定numRows,生成帕斯卡三
2015-02-03 17:50:15 1536
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人