Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted arraynums=[1,1,1,2,2,3],Your function should re... Read More
posted @ 2015-08-21 11:12 sunalive Views(116) Comments(0) Diggs(0)
You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?使用先对角线翻转,后水平翻转1 2 ... Read More
posted @ 2015-08-21 10:15 sunalive Views(192) Comments(0) Diggs(0)
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... Read More
posted @ 2015-08-20 14:59 sunalive Views(151) Comments(0) Diggs(0)
Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For examp... Read More
posted @ 2015-08-19 14:59 sunalive Views(157) Comments(0) Diggs(0)
Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->... Read More
posted @ 2015-08-19 14:46 sunalive Views(146) Comments(0) Diggs(0)
Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... Read More
posted @ 2015-08-13 10:17 sunalive Views(171) Comments(0) Diggs(0)
Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.1)O(m+n)算法:用两个数组,长度分别为m,n,如果有一个matrix[i][j] == 0,那么将数组col[j] ... Read More
posted @ 2015-08-10 19:38 sunalive Views(126) Comments(0) Diggs(0)
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo... Read More
posted @ 2015-08-08 22:39 sunalive Views(132) Comments(0) Diggs(0)
Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size that is great... Read More
posted @ 2015-08-08 20:25 sunalive Views(169) Comments(0) Diggs(0)
Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d... Read More
posted @ 2015-08-07 11:33 sunalive Views(125) Comments(0) Diggs(0)