随笔分类 -  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 阅读全文
posted @ 2019-11-29 01:43 Review->Improve 阅读(3307) 评论(0) 推荐(0)
摘要:Smaller input size: https://codeforces.com/contest/1249/problem/D1 Big input size: https://codeforces.com/contest/1249/problem/D2 Given n segments on 阅读全文
posted @ 2019-10-25 04:56 Review->Improve 阅读(589) 评论(0) 推荐(0)
摘要: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 = 阅读全文
posted @ 2019-09-29 06:26 Review->Improve 阅读(440) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-09-04 23:28 Review->Improve 阅读(882) 评论(0) 推荐(0)
摘要:mplement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given leng 阅读全文
posted @ 2019-08-07 12:06 Review->Improve 阅读(1275) 评论(0) 推荐(0)
摘要:LeetCode 424. Longest Repeating Character Replacement Given a string that consists of only uppercase English letters, you can replace any letter in th 阅读全文
posted @ 2019-04-13 03:48 Review->Improve 阅读(414) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-03-08 12:27 Review->Improve 阅读(622) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-03-04 00:14 Review->Improve 阅读(724) 评论(0) 推荐(0)
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Example 2: 阅读全文
posted @ 2019-03-02 13:20 Review->Improve 阅读(125) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-03-02 00:51 Review->Improve 阅读(1228) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-02-19 07:13 Review->Improve 阅读(1519) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-02-13 22:57 Review->Improve 阅读(186) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-02-10 10:20 Review->Improve 阅读(901) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-02-05 02:51 Review->Improve 阅读(1951) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-12-22 06:01 Review->Improve 阅读(307) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-12-22 02:35 Review->Improve 阅读(3069) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-12-15 05:59 Review->Improve 阅读(242) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-12-14 01:45 Review->Improve 阅读(1831) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-11-08 14:43 Review->Improve 阅读(396) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-09-27 12:55 Review->Improve 阅读(1781) 评论(0) 推荐(1)