摘要: 从右往左遍历 class Solution { public int maxProfit(int[] prices) { Map<Integer, Integer> priceMap = new HashMap<Integer, Integer>(); Integer leftMaxNum = nu 阅读全文
posted @ 2024-01-27 20:45 破忒头头 阅读(21) 评论(0) 推荐(0)
摘要: class Solution { public void rotate(int[] nums, int k) { if (k > nums.length){ k = k % nums.length; } reverse(nums, nums.length - k, nums.length-1); r 阅读全文
posted @ 2024-01-27 18:04 破忒头头 阅读(20) 评论(0) 推荐(0)
摘要: 快排 class Solution { public int majorityElement(int[] nums) { QuickSort(nums, 0, nums.length - 1); return nums[nums.length / 2]; } int partition(int[] 阅读全文
posted @ 2024-01-27 10:16 破忒头头 阅读(14) 评论(0) 推荐(0)