摘要: 二分查找目标数字的右边界+1的index以及比目标数字少1的数字的右边界+1,两者相减即为数字的个数 public class Solution { public int search(int[] nums, int target) { return find(nums, target) - fin 阅读全文
posted @ 2020-05-24 22:03 iamzhoug37 阅读(262) 评论(0) 推荐(0)
摘要: public class Solution { public int reversePairs(int[] nums) { if (nums.length < 2) { return 0; } int[] temp = new int[nums.length]; return mergeSort(n 阅读全文
posted @ 2020-05-24 21:33 iamzhoug37 阅读(579) 评论(0) 推荐(0)
摘要: https://leetcode-cn.com/problems/xu-lie-hua-er-cha-shu-lcof/ 就是层级遍历,搞一个queue,然后层级遍历,左右子树为空也要add到queue,因为要保留整颗树的结构,反解析的时候同理,遇到为null的,就不添加queue了 import 阅读全文
posted @ 2020-05-24 21:04 iamzhoug37 阅读(407) 评论(0) 推荐(0)