原创 362. Design Hit Counter

Design a hit counter which counts the number of hits received in the past 5 minutes. Each function accepts a timesta

原创 444. Sequence Reconstruction

Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. The org sequence

原创 307. Range Sum Query - Mutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, v

原创 130. Surrounded Regions

Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A region is captured

原创 310. Minimum Height Trees

For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a root

原创 379. Design Phone Directory

Design a Phone Directory which supports the following operations: get: Provide a number which is not assigned to an

原创 398. Random Pick Index

Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assu

原创 286. Walls and Gates

You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstacle.0 - A gate.INF

原创 382. Linked List Random Node

Given a singly linked list, return a random node's value from the linked list. Each node must have the same probabili

原创 399. Evaluate Division

Equations are given in the format A / B = k, where  A and B are variables represented as strings, and k is a real nu

原创 284. Peeking Iterator

Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that su

原创 348. Design Tic-Tac-Toe

Design a Tic-tac-toe game that is played between two players on a n x n grid. You may assume the following rules: A

原创 388. Longest Absolute File Path

Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\t

原创 560. Subarray Sum Equals K

Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equa

原创 604. Design Compressed String Iterator

Design and implement a data structure for a compressed string iterator. It should support the following operations: n