随笔分类 -  LeetCode

摘要:【题目】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,... 阅读全文
posted @ 2015-04-28 10:53 hwu_harry 阅读(117) 评论(0) 推荐(0)
摘要:【题目】Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. Y... 阅读全文
posted @ 2015-04-27 18:01 hwu_harry 阅读(141) 评论(0) 推荐(0)
摘要:【题目】Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:El... 阅读全文
posted @ 2015-04-27 16:15 hwu_harry 阅读(154) 评论(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 ma... 阅读全文
posted @ 2015-04-21 18:03 hwu_harry 阅读(107) 评论(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 ma... 阅读全文
posted @ 2015-04-21 17:33 hwu_harry 阅读(104) 评论(0) 推荐(0)
摘要:【问题】Given a collection of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Each num... 阅读全文
posted @ 2015-04-21 16:59 hwu_harry 阅读(100) 评论(0) 推荐(0)
摘要:【问题】Given a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thesamerepeated... 阅读全文
posted @ 2015-04-21 16:17 hwu_harry 阅读(84) 评论(0) 推荐(0)
摘要:【题目】Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a functio... 阅读全文
posted @ 2015-04-21 15:04 hwu_harry 阅读(118) 评论(0) 推荐(0)
摘要:【题目】Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3, You should return the following ... 阅读全文
posted @ 2015-04-21 14:30 hwu_harry 阅读(97) 评论(0) 推荐(0)
摘要:【题目】Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, ... 阅读全文
posted @ 2015-04-21 14:16 hwu_harry 阅读(118) 评论(0) 推荐(0)
摘要:题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target valu... 阅读全文
posted @ 2015-04-13 20:52 hwu_harry 阅读(125) 评论(0) 推荐(0)
摘要:题目:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ... 阅读全文
posted @ 2015-04-13 19:55 hwu_harry 阅读(102) 评论(0) 推荐(0)
摘要:问题:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space fo... 阅读全文
posted @ 2015-04-13 19:46 hwu_harry 阅读(139) 评论(0) 推荐(0)
摘要:题目:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find themaximum profit. You may complete... 阅读全文
posted @ 2015-04-13 14:39 hwu_harry 阅读(152) 评论(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 complet... 阅读全文
posted @ 2015-04-13 14:02 hwu_harry 阅读(139) 评论(0) 推荐(0)
摘要:题目:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction ... 阅读全文
posted @ 2015-04-13 13:51 hwu_harry 阅读(106) 评论(0) 推荐(0)
摘要:题目:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two... 阅读全文
posted @ 2015-04-08 11:13 hwu_harry 阅读(123) 评论(0) 推荐(0)