摘要: 双指针: leetcode167. 两数之和 II - 输入有序数组(双指针) leetcode 633.平方数之和(双指针 java) leetcode 345.反转字符串中的元音字母(双指针 java)(有地方不懂) leetcode 680.验证回文字符串 II(双指针 java) leetc 阅读全文
posted @ 2019-09-07 21:12 星辰大海。 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 1. 二维平面曲线作图函数 plot(x,y,'s'); x和y是长度相同的向量,s表示线型和颜色。也可以多条曲线作在同一张图上。。 2. 多窗口作图 subplot(m,n,k); 表示有m*n个窗口,当前图在第k个窗口。(窗口的顺序依次是从左到右,从上到下) 适用于画多个图的时候。 3. 直方图 阅读全文
posted @ 2019-10-24 23:37 星辰大海。 阅读(856) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List diffWaysToCompute(String input) { return partition(input); } public List partition(String input) { List result = new ArrayList(); ... 阅读全文
posted @ 2019-10-07 23:07 星辰大海。 阅读(197) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/ 二分查找详解: https://leetcode-cn.com/problems/find-first-and-last 阅读全文
posted @ 2019-09-28 10:23 星辰大海。 阅读(220) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/ 此题就是把数组分成两段,每一段都升序,并且前一段数字大于后一段。利用二分查找,如果nums[mid]<=nums[h],h=mid,其他情况都是l=mid+1 阅读全文
posted @ 2019-09-26 15:24 星辰大海。 阅读(131) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/first-bad-version/submissions/ 给定n个版本,根据isBadVersion(),判断第一个出错误,即值为true的版本号。 如果第 m 个版本出错,则表示第一个错误的版本在 [l, m] 之间,令 h = 阅读全文
posted @ 2019-09-25 15:49 星辰大海。 阅读(243) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/single-element-in-a-sorted-array/submissions/ 判断条件l<h,因为是判断单一元素,所以只需判断位于偶数位置的数字和下一个数字是否相等,来确定l和h的选择,要注意mid变量要一直为偶数。 阅读全文
posted @ 2019-09-24 21:29 星辰大海。 阅读(272) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/find-smallest-letter-greater-than-target/submissions/ 阅读全文
posted @ 2019-09-23 21:42 星辰大海。 阅读(235) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/sqrtx/ 实现int sqrt(int x)函数,给定一个数字,求sqrt(x)并且保留整数部分。 二分查找,令l=1,h=x,判断l<=h,当跳出循环时,即sqrt(x)不为整数时,return h,因为跳出循环时l>h,本题要 阅读全文
posted @ 2019-09-22 20:25 星辰大海。 阅读(393) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/partition-labels/submissions/ 划分字母区间,使同一个字母只能出现在一个区间。 贪心解决。 阅读全文
posted @ 2019-09-20 10:08 星辰大海。 阅读(401) 评论(0) 推荐(0) 编辑
摘要: https://leetcode-cn.com/problems/non-decreasing-array/submissions/ 给定数组,求去掉一个数是否能构成非递减数列。 遍历数组,用一个变量f来表示要去掉几个数才能使数列变成非递减数列。需要注意的是不能只判断nums[i-1]和nums[i 阅读全文
posted @ 2019-09-17 22:54 星辰大海。 阅读(311) 评论(0) 推荐(0) 编辑