dmndxld

码不停题

2019年5月11日

119. Pascal's Triangle II

摘要: Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note that the row index starts from 0. Follow up: Could 阅读全文

posted @ 2019-05-11 16:11 imyourterminal 阅读(140) 评论(0) 推荐(0) 编辑

2019年5月8日

189. Rotate Array

摘要: Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Note: Try to come up as many solutions as you can, there 阅读全文

posted @ 2019-05-08 21:22 imyourterminal 阅读(98) 评论(0) 推荐(0) 编辑

2019年5月7日

滑动窗口法学习

摘要: 刚才做了一道leecode题,要求是给定数组及数,返回最小的相邻子数组之和大于给定数的长度 这里我用循环套循环结果超出了时间限制,也就是说我的方法,时间复杂度很高,在遍历过程的一些信息被我丢失了 先贴代码 个人理解,就是用一个循环去替代原来的操作,减少时间复杂度。关键点就在于循环遍历时获取的信息,比 阅读全文

posted @ 2019-05-07 21:23 imyourterminal 阅读(1491) 评论(0) 推荐(0) 编辑

209. Minimum Size Subarray Sum

摘要: Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't 阅读全文

posted @ 2019-05-07 21:17 imyourterminal 阅读(104) 评论(0) 推荐(0) 编辑

485. Max Consecutive Ones

摘要: Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: My idea:for循环遍历,最后退出循环的时候也要判断,因为为1的时候我不能去给max赋值 那用双指针怎么做呢,参考 阅读全文

posted @ 2019-05-07 19:42 imyourterminal 阅读(104) 评论(0) 推荐(0) 编辑

27. Remove Element

摘要: Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another ar 阅读全文

posted @ 2019-05-07 18:06 imyourterminal 阅读(135) 评论(0) 推荐(0) 编辑

2019年5月6日

167. Two Sum II - Input array is sorted

摘要: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function 阅读全文

posted @ 2019-05-06 22:00 imyourterminal 阅读(108) 评论(0) 推荐(0) 编辑

561. Array Partition I

摘要: Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of 阅读全文

posted @ 2019-05-06 20:52 imyourterminal 阅读(110) 评论(0) 推荐(0) 编辑

344. Reverse String

摘要: Question: Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another 阅读全文

posted @ 2019-05-06 20:27 imyourterminal 阅读(164) 评论(0) 推荐(0) 编辑

14. 最长公共前缀

摘要: 题目: 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 说明: 所有输入只包含小写字母 a-z 。 思路:既然给我的是字符串数组,那我要比较的就不是两个元素了,所以考虑把这些元素的元素都一个一个取出来,放进空字符串里面,然后用字符串的count方 阅读全文

posted @ 2019-05-06 11:59 imyourterminal 阅读(136) 评论(0) 推荐(0) 编辑

导航