随笔分类 - Hash
摘要:1348. Tweet Counts Per Frequency Medium 130231Add to ListShare A social media company is trying to monitor activity on their site by analyzing the num
阅读全文
摘要:Design and implement a data structure for a Least Frequently Used (LFU) cache. Implement the LFUCache class: LFUCache(int capacity) Initializes the ob
阅读全文
摘要:Design a search autocomplete system for a search engine. Users may input a sentence (at least one word and end with a special character '#'). You are
阅读全文
摘要:You have a queue of integers, you need to retrieve the first unique integer in the queue. Implement the FirstUnique class: FirstUnique(int[] nums) Ini
阅读全文
摘要:You are given two string arrays username and website and an integer array timestamp. All the given arrays are of the same length and the tuple [userna
阅读全文
摘要:[抄题]: Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process only has one parent process, but ma
阅读全文
摘要:[抄题]: Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: A partially filled sudoku
阅读全文
摘要:[抄题]: public MyHashMap() { 主函数里面是装非final变量的,如果没有,可以一个字都不写 } [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: put: 不论如何都要放。所以如果没有bucke
阅读全文
摘要:[抄题]: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes usef
阅读全文
摘要:[抄题]: Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. Example 1: Example 2: [暴力解法]: 时间分析: 空间分析: [优
阅读全文
摘要:[抄题]: Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person. Person A will NOT friend reques
阅读全文
摘要:[抄题]: There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different wid
阅读全文
摘要:[抄题]: Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: Example 2: [暴力解法]: 时间分析: 空间分析: [
阅读全文
摘要:[抄题]: Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead. Note:The s
阅读全文
摘要:[抄题]: Given an array of strings, group anagrams together. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: 不知道k-v怎么存
阅读全文
摘要:[抄题]: Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences
阅读全文
摘要:[抄题]: Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by ot
阅读全文
摘要:[抄题]: Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You nee
阅读全文
摘要:[抄题]: We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1. Now, given an intege
阅读全文
摘要:[抄题]: he set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to anot
阅读全文