算法
文章平均质量分 73
lyf3068
这个作者很懒,什么都没留下…
展开
-
第四周OJ-Q122解题方法
问题 Best Time to Buy and Sell Stock IISay you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may comple原创 2017-03-19 20:50:13 · 200 阅读 · 0 评论 -
第十五周OJ-Q118解题方法
问题:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]这也是一个比较经典的问题了,其实就是做个原创 2017-06-08 17:15:38 · 468 阅读 · 0 评论 -
第十四周OJ-Q83解题方法
问题:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.这其实是个比较经典的问题了,删除链原创 2017-06-08 17:04:35 · 432 阅读 · 0 评论 -
第十三周OJ-Q58解题方法
问题:Given a string s consists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is原创 2017-06-08 16:49:23 · 338 阅读 · 0 评论 -
第十二周OJ-Q24解题方法
问题:Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should u原创 2017-06-06 16:02:09 · 262 阅读 · 0 评论 -
第八周 OJ-Q15解题方法
Given an array S of n integers, are there elements a,b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain du原创 2017-05-15 14:08:57 · 285 阅读 · 0 评论 -
第七周OJ-Q1解题方法
题目Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the原创 2017-04-09 22:21:03 · 262 阅读 · 0 评论 -
第六周OJ-Q392解题方法
题目:Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s andt. t is potentially a very long (length ~= 500,00原创 2017-04-09 21:53:53 · 171 阅读 · 0 评论 -
第三周OJ-Q402解题方法
问题Remove K Digits Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num原创 2017-03-14 13:15:09 · 305 阅读 · 0 评论 -
第五周OJ-Q123解题方法
问题:Best Time to Buy and Sell Stock IIISay you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complet原创 2017-03-27 21:06:48 · 286 阅读 · 0 评论 -
第十六周OJ-Q134解题方法
问题:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station原创 2017-07-01 21:48:03 · 397 阅读 · 0 评论