摘要: 这道题为简单题 题目: 思路: 这道题其实很简单,但是我之前做出来总是超时,于是就优化了一下代码,创建一个列表a,长度为len(nums)+1初始化为0,遍历列表nums,把对应列表a的索引变为1,最后用列表生成式返回a[i]为0的索引 代码: 阅读全文
posted @ 2017-09-22 22:52 唐僧洗发爱飘柔 阅读(111) 评论(0) 推荐(0)
摘要: 这道题为简单题 题目: 思路: 最开始我只是在sumRange里面写函数,写出来之后总是超时,在查询之后才知道有些东西要写在init之中,所以我先遍历数组,把数组的第n个元素的值变为前n个元素值之和,然后传入sumRange。 代码: 阅读全文
posted @ 2017-09-22 13:10 唐僧洗发爱飘柔 阅读(98) 评论(0) 推荐(0)
摘要: 这道题为简单题 题目: 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 w 阅读全文
posted @ 2017-09-22 00:10 唐僧洗发爱飘柔 阅读(143) 评论(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 ex 阅读全文
posted @ 2017-09-22 00:06 唐僧洗发爱飘柔 阅读(81) 评论(0) 推荐(0)