上一页 1 ··· 5 6 7 8 9 10 11 12 13 14 下一页

2013年10月12日

Count and Say

摘要: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw... 阅读全文

posted @ 2013-10-12 12:51 Step-BY-Step 阅读(232) 评论(0) 推荐(0) 编辑

2013年10月11日

Combination Sum

摘要: Given a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thesamerepeated num... 阅读全文

posted @ 2013-10-11 13:12 Step-BY-Step 阅读(187) 评论(0) 推荐(0) 编辑

First Missing Positive

摘要: Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should ru... 阅读全文

posted @ 2013-10-11 13:10 Step-BY-Step 阅读(124) 评论(0) 推荐(0) 编辑

Trapping Rain Water

摘要: 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-10-11 11:58 Step-BY-Step 阅读(151) 评论(0) 推荐(0) 编辑

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,... 阅读全文

posted @ 2013-10-11 11:56 Step-BY-Step 阅读(179) 评论(0) 推荐(0) 编辑

Single Number II

摘要: Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?创建一个长度为32的数组a,a[i]表示所有数字在i位出现的次数。假如a[i]是3的整数倍,则忽略;否则就把该位取出来组成答案。空间复杂度O(1).int sol1(int A[], 阅读全文

posted @ 2013-10-11 11:17 Step-BY-Step 阅读(278) 评论(0) 推荐(0) 编辑

Single Number

摘要: Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?这题是Amazon的经典面试题。 最简单的解法是用hashmap,O(n)即可。但是要用额外的存储空间。或者是维持一个数组,用于存放没有被配对的数。用二分来更新这个数组,如果数组中没有当前数就加入 阅读全文

posted @ 2013-10-11 11:06 Step-BY-Step 阅读(212) 评论(0) 推荐(0) 编辑

Copy List with Random Pointer

摘要: Question: There is a doubly linked list with next pointer and random pointer (points to an arbitrary node in list). You have to make a copy of the linked list and return. In the end original list shouldn't be modified. Time complexity should be O(n).这个是微软经典list题目之一: 铁索连舟. 本来是想自己写一篇总结的, 但是网上那篇英文的 阅读全文

posted @ 2013-10-11 08:25 Step-BY-Step 阅读(936) 评论(0) 推荐(1) 编辑

2013年10月9日

Word Break II

摘要: Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens="catsanddog",dict=["cat", "cats", "and", "sand", "dog"].A 阅读全文

posted @ 2013-10-09 14:01 Step-BY-Step 阅读(354) 评论(0) 推荐(0) 编辑

Word Break

摘要: Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For example, givens="leetcode",dict=["leet", "code"].Return true because"leetcode"can be segmented as"leet code&quo 阅读全文

posted @ 2013-10-09 11:32 Step-BY-Step 阅读(223) 评论(0) 推荐(0) 编辑

Rotate Image

摘要: You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place? 1 public class Sol... 阅读全文

posted @ 2013-10-09 08:31 Step-BY-Step 阅读(203) 评论(0) 推荐(0) 编辑

2013年10月4日

N-Queens

摘要: Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinct solutions to then-queens puzzle.Each solution contains a distinct board configuration of then-queens' placement, where'Q'and'.& 阅读全文

posted @ 2013-10-04 12:28 Step-BY-Step 阅读(206) 评论(0) 推荐(0) 编辑

Pow(x, n)

摘要: Implement pow(x,n). 1 public class Solution { 2 public double pow(double x, int n) { 3 // Start typing your Java solution below 4 ... 阅读全文

posted @ 2013-10-04 12:22 Step-BY-Step 阅读(205) 评论(0) 推荐(0) 编辑

Maximum Subarray

摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,... 阅读全文

posted @ 2013-10-04 12:17 Step-BY-Step 阅读(107) 评论(0) 推荐(0) 编辑

Spiral Matrix

摘要: Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],... 阅读全文

posted @ 2013-10-04 12:07 Step-BY-Step 阅读(148) 评论(0) 推荐(0) 编辑

Jump Game

摘要: 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 maximu... 阅读全文

posted @ 2013-10-04 08:05 Step-BY-Step 阅读(191) 评论(0) 推荐(0) 编辑

Merge Intervals

摘要: Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].复用 Insert Interval代码即可。 1 /** 2 * Definition for an interval. 3 * public class Interval { 4 * int start; 5 * int end; 6 * Interval() { start = 0; e... 阅读全文

posted @ 2013-10-04 08:04 Step-BY-Step 阅读(241) 评论(0) 推荐(0) 编辑

Insert Interval

摘要: Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example 1:Given intervals[1,3],[6,9], insert and merge[2,5]in as[1,5],[6,9].Example 2:Given[1,2],[3,5],[6,7],[8 阅读全文

posted @ 2013-10-04 07:35 Step-BY-Step 阅读(232) 评论(0) 推荐(0) 编辑

Length of Last Word

摘要: Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe... 阅读全文

posted @ 2013-10-04 06:46 Step-BY-Step 阅读(217) 评论(0) 推荐(0) 编辑

Spiral Matrix II

摘要: Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matri... 阅读全文

posted @ 2013-10-04 06:20 Step-BY-Step 阅读(172) 评论(0) 推荐(0) 编辑

Amazon 面经

摘要: [版面:待字闺中][首篇作者:gmadj] , 2013年09月29日21:51:33[首页] [上页][下页][末页] [分页:12]gmadj进入未名形象秀我的博客[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报][ 1 ]发信人: gmadj (姑妈爱大舅), 信区: JobHunting标 题: 分享一下面试题目 with update发信站: BBS 未名空间站 (Sun Sep 29 21:51:33 2013, 美东)update一下,周一,也就是昨天,已经拿到offer,具体数目还不明了=============== 阅读全文

posted @ 2013-10-04 05:20 Step-BY-Step 阅读(543) 评论(0) 推荐(0) 编辑

Permutation Sequence

摘要: The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, forn= 3):"123""132""213""231""312""321"Givennandk, return thekthpermutation sequence.Not 阅读全文

posted @ 2013-10-04 02:51 Step-BY-Step 阅读(225) 评论(0) 推荐(0) 编辑

2013年10月3日

Rotate List

摘要: Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.最开始想直接用双指针做就行了。 但是发现n竟然可以比length长。 1 /** 2 * Definition for singly-linked list. 3 * public class ListNode { 4 * int val; 5 * 阅读全文

posted @ 2013-10-03 15:14 Step-BY-Step 阅读(225) 评论(0) 推荐(0) 编辑

G家二面

摘要: 题目都很基本,都属于听说过但是不会做的…都是操作系统,compiler的概念题…概念题郁闷就郁闷在不会就是不会,就算能扯两句也会被问倒…算法就一个,pow(x, y),5分钟不到……不是听说G家都问算法吗……T_T看来以后还是得把CS的基本课过一遍…作为EE的人表示亚历山大啊 阅读全文

posted @ 2013-10-03 13:09 Step-BY-Step 阅读(167) 评论(0) 推荐(0) 编辑

Candy

摘要: There areNchildren 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 candy.Children with a higher rating get more candies than their neighbors.What is the minimum candies you mu 阅读全文

posted @ 2013-10-03 08:55 Step-BY-Step 阅读(233) 评论(0) 推荐(0) 编辑

Unique Paths II

摘要: A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文

posted @ 2013-10-03 03:42 Step-BY-Step 阅读(151) 评论(0) 推荐(0) 编辑

Minimum Path Sum

摘要: Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:Yo... 阅读全文

posted @ 2013-10-03 03:16 Step-BY-Step 阅读(199) 评论(0) 推荐(0) 编辑

2013年10月2日

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. 1 /** 2 ... 阅读全文

posted @ 2013-10-02 14:40 Step-BY-Step 阅读(160) 评论(0) 推荐(0) 编辑

Add Binary

摘要: Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100". 1 public class Solution { 2 public String addBinary(String a, String b) { 3 // Start typing your Java solution below 4 // DO NOT write main() function 5 StringBuffer 阅读全文

posted @ 2013-10-02 07:53 Step-BY-Step 阅读(176) 评论(0) 推荐(0) 编辑

Valid Number

摘要: Validate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the problem stat... 阅读全文

posted @ 2013-10-02 07:19 Step-BY-Step 阅读(280) 评论(0) 推荐(0) 编辑

Plus One

摘要: Given a number represented as an array of digits, plus one to the number. 1 public class Solution { 2 public int[] plusOne(int[] digits) { 3 // Start typing your Java solution below 4 // DO NOT write main() function 5 int carry = 0; 6 boolean sig = false; 7 ... 阅读全文

posted @ 2013-10-02 07:13 Step-BY-Step 阅读(203) 评论(0) 推荐(0) 编辑

Text Justification

摘要: Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces' 'when necessary so that each line 阅读全文

posted @ 2013-10-02 05:22 Step-BY-Step 阅读(212) 评论(0) 推荐(0) 编辑

Sqrt(x)

摘要: Implementint sqrt(int x).Compute and return the square root ofx.牛顿迭代法: 1 public class Solution { 2 double eps = 0.000001; 3 public int sqrt(in... 阅读全文

posted @ 2013-10-02 05:09 Step-BY-Step 阅读(632) 评论(0) 推荐(0) 编辑

Corner case

摘要: Acorner case(orpathological case) is a problem or situation that occurs only outside of normal operatingparameters—specifically one that manifests itself when multiple environmental variables or conditions are simultaneously at extreme levels, even though each parameter is within the specified range 阅读全文

posted @ 2013-10-02 04:22 Step-BY-Step 阅读(570) 评论(0) 推荐(0) 编辑

Simplify Path

摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to show corner cas... 阅读全文

posted @ 2013-10-02 04:18 Step-BY-Step 阅读(343) 评论(0) 推荐(0) 编辑

2013年10月1日

Combinations

摘要: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]Solution:采用位运算来做,但是这样时间复杂度很高O(n* 2^ n)。 1 public class Solution { 2 public ArrayList> combine(int n, int k) { 3 /... 阅读全文

posted @ 2013-10-01 14:42 Step-BY-Step 阅读(149) 评论(0) 推荐(0) 编辑

Search a 2D Matrix

摘要: Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row is greater than the last integer of the previous row.For example,Consider the following matrix:[ [1, 3, ... 阅读全文

posted @ 2013-10-01 14:25 Step-BY-Step 阅读(161) 评论(0) 推荐(0) 编辑

Set Matrix Zeroes

摘要: Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution using O(mn) space is probably a bad idea.A simple improvement uses O(m+n) space, but still not the best solution.Could you de 阅读全文

posted @ 2013-10-01 13:44 Step-BY-Step 阅读(204) 评论(0) 推荐(0) 编辑

Edit Distance

摘要: Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a) Insert a characterb) Delete a characterc) Replace a characterSolution:第一遍做的时候没弄懂应该怎么做,只是有个感觉应该是DP。对于一个位置,它有 阅读全文

posted @ 2013-10-01 12:49 Step-BY-Step 阅读(164) 评论(0) 推荐(0) 编辑

Sort Colors

摘要: Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文

posted @ 2013-10-01 11:40 Step-BY-Step 阅读(134) 评论(0) 推荐(0) 编辑

上一页 1 ··· 5 6 7 8 9 10 11 12 13 14 下一页

导航