Spurs

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2017年8月14日

摘要: 119. Pascal's Triangle II Given an index $k$, return the $k^{th}$ row of the Pascal's triangle. For example, given $k = 3$, Return . 直接生成由0组成的数组,设定 ,迭 阅读全文
posted @ 2017-08-14 11:53 英雄与侠义的化身 阅读(74) 评论(0) 推荐(0) 编辑

摘要: 88. Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 ha 阅读全文
posted @ 2017-08-14 11:52 英雄与侠义的化身 阅读(80) 评论(0) 推荐(0) 编辑

摘要: 118. Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, given , Return 在每一行后面+1, 再更新该行. 另外学会向 容器中放 元素. 人家代 阅读全文
posted @ 2017-08-14 11:52 英雄与侠义的化身 阅读(110) 评论(0) 推荐(0) 编辑

摘要: 66. Plus One Given a non negative integer represented as a non empty array of digits, plus one to the integer. 该题目要求:将一整数按位存储在vector中,对其实现+1操作,返回结果. 对 阅读全文
posted @ 2017-08-14 11:51 英雄与侠义的化身 阅读(101) 评论(0) 推荐(0) 编辑

摘要: 53. Maximum Subarray 同121题. Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, give 阅读全文
posted @ 2017-08-14 11:50 英雄与侠义的化身 阅读(112) 评论(0) 推荐(0) 编辑

摘要: Given an array , write a function to move all 's to the end of it while maintaining the relative order of the non zero elements. For example, given , 阅读全文
posted @ 2017-08-14 11:47 英雄与侠义的化身 阅读(85) 评论(0) 推荐(0) 编辑

摘要: 268. Missing Number Given an array containing $n$ distinct numbers taken from , find the one that is missing from the array. For example, Given return 阅读全文
posted @ 2017-08-14 10:45 英雄与侠义的化身 阅读(97) 评论(0) 推荐(0) 编辑

2017年8月13日

摘要: 1. Two Sum 人家媳妇: time $O(n)$, space $O(n)$ 方法中巧妙使用map,一次遍历完成任务. 遍历数组时,若未在map中找到想要的元素,则把数组中当前元素投入map.(注key=数组元素值,val=该元素indx) c++ vector twoSum(vector 阅读全文
posted @ 2017-08-13 13:49 英雄与侠义的化身 阅读(112) 评论(0) 推荐(0) 编辑

摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2017-08-13 13:40 英雄与侠义的化身 阅读(174) 评论(0) 推荐(0) 编辑

摘要: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space fo 阅读全文
posted @ 2017-08-13 13:38 英雄与侠义的化身 阅读(105) 评论(0) 推荐(0) 编辑