随笔分类 - Data Structures
摘要:A quack is a data structure combining properties of both stacks and queues. It can be viewed as a list of elements written left to right such that thr
阅读全文
摘要:Smaller input size: https://codeforces.com/contest/1249/problem/D1 Big input size: https://codeforces.com/contest/1249/problem/D2 Given n segments on
阅读全文
摘要:Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums =
阅读全文
摘要:Given a string s, we make queries on substrings of s. For each query queries[i] = [left, right, k], we may rearrange the substring s[left], ..., s[rig
阅读全文
摘要:mplement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given leng
阅读全文
摘要:LeetCode 424. Longest Repeating Character Replacement Given a string that consists of only uppercase English letters, you can replace any letter in th
阅读全文
摘要:Graph: n nodes, m edges Representation Adjacency Matrix: O(n^2) space, not efficient for sparse graph Adjacency List: O(n + m) space, efficient for sp
阅读全文
摘要:We are given that the string "abc" is valid. From any valid string V, we may split V into two pieces X and Y such that X + Y (X concatenated with Y) i
阅读全文
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Example 2:
阅读全文
摘要:Given an array of integers A, find the sum of min(B), where B ranges over every (contiguous) subarray of A. Since the answer may be large, return the
阅读全文
摘要:In an array A containing only 0s and 1s, a K-bit flip consists of choosing a (contiguous) subarray of length K and simultaneously changing every 0 in
阅读全文
摘要:Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence. For example, in the given t
阅读全文
摘要:Given a binary tree, return the vertical order traversal of its nodes values. For each node at position (X, Y), its left and right children respective
阅读全文
摘要:This problem was asked by Google. On our special chessboard, two bishops attack each other if they share the same diagonal. This includes bishops that
阅读全文
摘要:Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k num
阅读全文
摘要:This problem was asked by Google. Implement locking in a binary tree. A binary tree node can be locked or unlocked only if all of its descendants or a
阅读全文
摘要:Implement a trie with insert, search, and startsWith methods. Notice You may assume that all inputs are consist of lowercase letters a-z. Implement a
阅读全文
摘要:This problem was asked by Twitter. You run an e-commerce website and want to record the last N order ids in a log. Implement a data structure to accom
阅读全文
摘要:Given an integer array, heapify it into a min-heap array. For a heap array A, A[0] is the root of heap, and for each A[i], A[i * 2 + 1] is the left ch
阅读全文
摘要:Given a list of Connections, which is the Connection class (the city name at both ends of the edge and a cost between them), find some edges, connect
阅读全文

浙公网安备 33010602011771号