
LeetCode in Java
Spencer_Lin
If you fight for your dream, one day....
展开
-
Valid Sudoku Java
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 fille原创 2014-08-07 14:40:53 · 380 阅读 · 0 评论 -
Trapping Rain Water Java
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1],原创 2014-08-12 10:13:34 · 451 阅读 · 0 评论 -
Candy Java
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 least one原创 2014-08-13 15:03:53 · 378 阅读 · 0 评论 -
Search for a Range Java
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found in t原创 2014-08-14 05:19:18 · 297 阅读 · 0 评论 -
Search Insert Position Java
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.原创 2014-08-14 05:10:18 · 376 阅读 · 0 评论 -
Climbing Stairs Java
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?原创 2014-08-21 17:22:00 · 333 阅读 · 0 评论 -
Reverse Integer Java
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321public class Solution { public int reverse(int x) { boolean negSign=false;原创 2014-08-15 16:29:36 · 341 阅读 · 0 评论