- 博客(13)
- 资源 (1)
- 收藏
- 关注
原创 Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x.public class Solution { public int sqrt(int x) { if(x == 0 || x==1) return x; int low = 1, high =
2014-05-19 23:06:13 686
原创 【DP】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?public class Solution {
2014-05-19 21:54:29 559
原创 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.public class Solutio
2014-05-19 21:03:01 503
原创 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) {
2014-05-19 20:49:12 573
原创 【链表】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./** * Definition for singly-linked list. * public c
2014-05-19 20:21:22 469
原创 【区间合并】Insert Interval
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.E
2014-05-19 11:43:47 522
原创 【区间合并】Merge Intervals
/** * Definition for an interval. * public class Interval { * int start; * int end; * Interval() { start = 0; end = 0; } * Interval(int s, int e) { start = s; end = e; } * } */
2014-05-19 11:32:57 566
原创 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
2014-05-18 16:59:37 512
原创 Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [
2014-05-18 16:43:14 405
原创 【排列】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""231""3
2014-05-18 16:23:55 458
原创 【链表】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.链表右移K位public class Solution {
2014-05-15 22:42:13 515
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人