- 博客(26)
- 资源 (8)
- 收藏
- 关注
原创 [leetcode]Binary Tree Postorder Traversal
题目: Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Recursiv
2015-01-08 17:32:38 163
原创 [leetcode]Binary Tree Inorder Traversal
题目:Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Note: Recursive solu
2015-01-08 17:29:54 197
原创 [leetcode]Binary Tree Preorder Traversal
题目: Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive
2015-01-08 17:27:46 152
原创 [leetcode]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 bee
2014-12-17 16:11:02 242
原创 [leetcode]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 pla
2014-12-17 16:06:41 178
原创 [leetcode]Reverse Nodes in k-Group
题目: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain a
2014-12-17 16:03:52 134
原创 [leetcode]Swap Nodes in Pairs
题目: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant s
2014-12-17 16:02:15 200
原创 [leetcode]Generate Parentheses
题目: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: "((()))", "(()())", "(())()", "()(())"
2014-12-17 15:42:50 211
原创 [leetcode]Valid Parentheses
题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are
2014-12-17 15:39:39 154
原创 [leetcode]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 e
2014-12-17 15:37:29 124
原创 [leetcode]4Sum
题目: 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:
2014-12-17 15:33:36 133
原创 [leetcode]Letter Combinations of a Phone Number
题目: Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:D
2014-12-17 15:30:16 234
原创 [leetcode]3Sum Closest
题目: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have
2014-12-17 15:27:34 247
原创 [leetcode]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
2014-12-17 15:23:44 116
原创 [leetcode]Longest Common Prefix
题目:Write a function to find the longest common prefix string amongst an array of strings. 链接:https://oj.leetcode.com/problems/longest-common-prefix/ 描述:找出字符串数组中的最长公共前缀 solution by python: class So
2014-12-17 15:22:21 118
原创 [leetcode]Roman to Integer
题目: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 链接:https://oj.leetcode.com/problems/roman-to-integer/ 描述:把罗马数字转换成整形 solut
2014-12-17 15:20:14 171
原创 [leetcode]Integer to Roman
题目: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 链接:https://oj.leetcode.com/problems/integer-to-roman/ 描述:把整形转化为罗马数字 solut
2014-12-17 15:17:27 272
原创 [leetcode]Container With Most Water
题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i,
2014-12-17 15:11:55 156
原创 [leetcode]Regular Expression Matching
题目: Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the enti
2014-12-17 14:56:28 201
原创 [leetcode]Palindrome Number
题目:验证一个数是不是回文数 链接:https://oj.leetcode.com/problems/palindrome-number/ 描述:每次取最高位和最低位比较是否相同,注意负数不是回文数 solution by python:class Solution: # @return a boolean def isPalindrome(self, x):
2014-12-17 14:53:00 106
原创 [leetcode]Reverse Integer
题目: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 链接:https://oj.leetcode.com/problems/reverse-integer/ 解法:直接处理,注意溢出,leetcode加强了判题现在要处理溢出,以前的代
2014-12-17 14:46:27 210
原创 [leetcode]ZigZag Conversion
题目: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P
2014-12-17 14:41:35 132
原创 [leetcode]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. 链接:https://oj.l
2014-12-17 14:28:16 134
原创 [leetcode] Longest Substring Without Repeating Characters
题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3.
2014-12-17 14:15:04 1205
原创 [leetcode]Median of Two Sorted Arrays
题目:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 描述:对数时间复杂度寻找两个数组中的中位数 思路:实现
2014-12-17 11:28:58 172
原创 [leetcode]Two Sum
题目: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the targ
2014-12-17 11:18:49 168
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人