随笔分类 -  Heap

摘要:Given a string s and an integer k, rearrange s such that the same characters are at least distance k from each other. If it is not possible to rearran 阅读全文
posted @ 2022-10-02 05:48 苗妙苗 阅读(30) 评论(0) 推荐(0)
摘要:用max heap // use maxHeap. Put entry into maxHeap so we can always poll a number with largest frequency public class Solution { public List<Integer> to 阅读全文
posted @ 2022-05-02 05:52 苗妙苗 阅读(87) 评论(0) 推荐(0)
摘要:参考:https://www.geeksforgeeks.org/min-heap-in-java/ 最小堆是如何表示的?最小堆是一棵完全二叉树。最小堆通常表示为一个数组。根元素将在Arr[0] 处。对于任何第 i 个节点,即Arr[i]:Arr[(i -1) / 2]返回其父节点。Arr[(2 * 阅读全文
posted @ 2021-06-03 06:47 苗妙苗 阅读(237) 评论(0) 推荐(0)
摘要:[抄题]: You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element f 阅读全文
posted @ 2018-08-24 04:31 苗妙苗 阅读(158) 评论(0) 推荐(0)
摘要:[抄题]: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇 阅读全文
posted @ 2018-07-30 16:00 苗妙苗 阅读(202) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conferenc 阅读全文
posted @ 2018-05-08 21:19 苗妙苗 阅读(157) 评论(0) 推荐(0)