摘要: Givennnon-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], return6.The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of 阅读全文
posted @ 2013-09-06 02:11 LEDYC 阅读(174) 评论(0) 推荐(0)
摘要: Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.---09/21, Review顺序,最高位是0要去掉public class Solution { public String multiply(String num1, String num2) { if (num1.equals("0") || num... 阅读全文
posted @ 2013-09-06 01:36 LEDYC 阅读(161) 评论(0) 推荐(0)
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of jumps.For example:Given array A =[2,3,1,1,4]The minimum n 阅读全文
posted @ 2013-09-06 01:16 LEDYC 阅读(148) 评论(0) 推荐(0)
摘要: 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].---参考cc150 9.5O(N!) N factorial---1. Interationpublic class Solution { public ArrayList> permute(int[] num) { Array... 阅读全文
posted @ 2013-09-06 00:46 LEDYC 阅读(156) 评论(0) 推荐(0)