上一页 1 ··· 3 4 5 6 7
摘要: 1. Integer to String: Integer.toString(num) 或者 直接 num + "" 2. valueOf 的使用: String 和Integer 都有valueOf 函数 Integer.valueOf("123") Integer.valueOf("1ff", 阅读全文
posted @ 2018-10-27 02:43 KeepAC 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 参考 : https://www.jianshu.com/p/bb82dca89e2d Divide-and-conquer merge sort 的核心理念是 Divide-and-conquer ,这个范式的核心是把问题分割成跟原问题相似的子问题,然后,递归的解决这些子问题,最后把这些子问题的结 阅读全文
posted @ 2018-10-22 13:14 KeepAC 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 题意: Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. 这种不能破坏 i 和j “相对关系” 的情况去统计一些结果的题,都可以考虑merge sort. m 阅读全文
posted @ 2018-10-22 05:19 KeepAC 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined as the sum of the eleme 阅读全文
posted @ 2018-10-22 05:03 KeepAC 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 这题 和 327. Count of Range Sum and 493. Reverse Pairs 几乎一样的解法,都属于hard 题, 可以用 merge sort, segment tree 和 BST 去求解。 注意如果自己去实现简单的BST, 在数组已经排序好的情况下 比 [1 2 3 阅读全文
posted @ 2018-10-22 04:10 KeepAC 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 1. 排序: Array: Arrays.sort(intervals, (o1,o2)->o1.start-o2.start); //可以是一个ClassList : intervals.sort((o1,o2)->(o1.start-o2.start)); //intervals 本身是一个Cl 阅读全文
posted @ 2018-10-20 14:44 KeepAC 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 这题本质上是贪心法, 一个原则 “只有比你身高高的或者相等的才对你有影响,插入任何比你小的人都对你没影响” 因此从大到小排列,先处理大的,再处理小的。每次处理时K 就是插入的位置,因为前面人的身高都比你高或者一样,所以你的K 是多少就决定了你的下标。 people: [[7,0], [4,4], [ 阅读全文
posted @ 2018-10-20 14:34 KeepAC 阅读(68) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7