随笔分类 - 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
阅读全文
摘要:用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
阅读全文
摘要:参考:https://www.geeksforgeeks.org/min-heap-in-java/ 最小堆是如何表示的?最小堆是一棵完全二叉树。最小堆通常表示为一个数组。根元素将在Arr[0] 处。对于任何第 i 个节点,即Arr[i]:Arr[(i -1) / 2]返回其父节点。Arr[(2 *
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇
阅读全文
摘要:[抄题]: 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
阅读全文