
刷题啦
文章平均质量分 65
yanrui92
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
leetcode-palindrome number
public boolean isPalindrome(int x) { if(x<0)return false; int y=0; int z=x; while(z>0){ int cur=z%10; y=y*10+cur; z=z/10; }原创 2015-01-08 13:23:15 · 357 阅读 · 0 评论 -
leetcode-find peak number
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple peaks, i原创 2015-01-11 02:43:38 · 523 阅读 · 0 评论 -
leetcode-climbing stairs
Climbing Stairs Total Accepted: 36520 Total Submissions: 107274My Submissions Question Solution You are climbing a stair case. It takes n steps to reach to the top. Each time you原创 2015-01-10 05:14:02 · 299 阅读 · 0 评论 -
leetcode-edit distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word:原创 2015-01-10 05:44:38 · 307 阅读 · 0 评论 -
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 L S I原创 2015-01-18 08:58:46 · 292 阅读 · 0 评论 -
leetcode-anagrams
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. public class Solution { public List anagrams(String[] strs) { HashM原创 2015-01-19 12:08:09 · 344 阅读 · 0 评论 -
leetcode-valid parenthesses
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 all va原创 2015-01-18 09:40:08 · 345 阅读 · 0 评论 -
leetcode-first missing element
Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses constant原创 2015-01-20 11:10:17 · 410 阅读 · 0 评论 -
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 target, whe原创 2015-01-20 00:51:36 · 263 阅读 · 0 评论 -
leetcode-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原创 2015-01-21 08:24:33 · 350 阅读 · 0 评论 -
leetcode-min stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get原创 2015-01-20 11:51:04 · 265 阅读 · 0 评论 -
leetcode-unique binary search tree II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n = 3, your program should return all 5 unique BST's shown below. public class原创 2015-01-28 07:20:44 · 305 阅读 · 0 评论 -
leetcode-3Sum总结
public class Solution { public List> threeSum(int[] num) { ArrayList> result=new ArrayList>(); int len=num.length; if(len==0)return result; Arrays.sort(num);原创 2015-01-06 03:26:58 · 400 阅读 · 0 评论 -
leetcode-trapping rain water
Trapping rain water的最naive的方法:onepass 没有注意到的问题: 1一个container的两端应该是取最小的高度。 2在找第一个容器的左端的时候没有注意到数组的下标的界限的问题!注意当数组的下标有变化的时候一定紧跟着不要忘记对其范围进行限制。 3解题思路是:先找到第一个容器的最左端的点,然后用一个函数去找这个容器的右端,这个右端或者是大于等于这个容器的左端,原创 2015-01-08 04:43:34 · 403 阅读 · 0 评论 -
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: "((()))", "(()())", "(())()", "()(())", "()()原创 2015-01-08 05:13:09 · 310 阅读 · 0 评论 -
leetcode-Permutations
Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. public class原创 2015-01-09 10:05:48 · 374 阅读 · 0 评论 -
leetcode-3 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 exac原创 2015-01-08 04:52:00 · 344 阅读 · 0 评论 -
leetcode-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 link原创 2015-01-09 05:16:57 · 301 阅读 · 0 评论 -
leetcode-add binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". public class Solution { public String addBinary(String a, String b) {原创 2015-01-09 06:06:15 · 340 阅读 · 0 评论 -
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: Element原创 2015-01-08 05:02:03 · 288 阅读 · 0 评论 -
leetcode-letter combination 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:Digit st原创 2015-01-08 06:04:27 · 330 阅读 · 0 评论 -
leetcode-sum root to leaf numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the tota原创 2015-01-08 11:25:58 · 441 阅读 · 0 评论 -
leetcode-valid 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 key.Th原创 2015-01-28 03:57:00 · 292 阅读 · 0 评论 -
leetcode-binary tree maximum path sum
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree, public class Solution { int result=Integer.M原创 2015-01-28 09:33:16 · 359 阅读 · 0 评论 -
leetcode-set Matrix Zero
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. public class Solution { public void setZeroes(int[][] matrix) { int[] row=new int[matrix.le原创 2015-02-19 10:23:53 · 371 阅读 · 0 评论