摘要: 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... 阅读全文
posted @ 2015-10-29 22:58 eversliver 阅读(223) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文
posted @ 2015-10-29 22:23 eversliver 阅读(243) 评论(0) 推荐(0) 编辑
摘要: Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ... 阅读全文
posted @ 2015-10-29 21:52 eversliver 阅读(231) 评论(0) 推荐(0) 编辑
摘要: You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?题目要就地算法,那么可以通过折叠矩阵上... 阅读全文
posted @ 2015-10-29 20:34 eversliver 阅读(235) 评论(0) 推荐(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... 阅读全文
posted @ 2015-10-29 19:58 eversliver 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 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 ord... 阅读全文
posted @ 2015-10-29 19:22 eversliver 阅读(294) 评论(0) 推荐(0) 编辑
摘要: Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.这题要注意的就是应该是就地执行,所以可以先采取一个数组将所有0元素的位置记下来,然后一次性的全部置成0即可: 1 clas... 阅读全文
posted @ 2015-10-29 17:12 eversliver 阅读(237) 评论(0) 推荐(0) 编辑
摘要: Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文
posted @ 2015-10-29 11:48 eversliver 阅读(305) 评论(0) 推荐(0) 编辑
摘要: Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size that is great... 阅读全文
posted @ 2015-10-29 11:00 eversliver 阅读(241) 评论(0) 推荐(0) 编辑