摘要: 118 题目:又叫“杨辉三角形” Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum o 阅读全文
posted @ 2018-05-03 22:11 何以解忧,唯有撸代码 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 题目:将两个有序数组合并成一个 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized 阅读全文
posted @ 2018-05-03 21:32 何以解忧,唯有撸代码 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significa 阅读全文
posted @ 2018-05-02 20:56 何以解忧,唯有撸代码 阅读(633) 评论(0) 推荐(0) 编辑
摘要: 求连续子数组的最大和,这道题是面试经典问题。《算法导论》中提供了分治的解法,但是DP解法是最快的, 能达到O(N)。 思路:若当前的和小于0,则应该抛弃当前的和,重新开始求和。有一些边界条件需要注意: 1.数组长度为1时,直接返回该值; 2.数组元素均为负数时,问题就变成了找数组的最大元素。需要判断 阅读全文
posted @ 2018-05-02 19:57 何以解忧,唯有撸代码 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a string, find the length of the longest substring without repeating characters. 思路:用一个表(数组)来存储字符在字符串中的位置。因为字符本质上是一个unicode数字,因此建立一个数组,数组的下标表 阅读全文
posted @ 2018-04-26 14:55 何以解忧,唯有撸代码 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra 阅读全文
posted @ 2018-04-26 09:32 何以解忧,唯有撸代码 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 题目: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes co 阅读全文
posted @ 2018-04-26 08:33 何以解忧,唯有撸代码 阅读(139) 评论(0) 推荐(0) 编辑