Leetcode 2021-12-11

381. Insert Delete GetRandom O(1) - Duplicates allowed (Hard)

RandomizedCollection is a data structure that contains a collection of numbers, possibly duplicates (i.e., a multiset). It should support inserting and removing specific elements and also removing a random element.

阅读全文 »

Leetcode 2021-12-09

361. Bomb Enemy (Medium)

Given an m x n matrix grid where each cell is either a wall 'W', an enemy 'E' or empty '0', return the maximum enemies you can kill using one bomb. You can only place the bomb in an empty cell.

阅读全文 »

Leetcode 2021-12-08

351. Android Unlock Patterns (Medium)

Android devices have a special lock screen with a 3 x 3 grid of dots. Users can set an "unlock pattern" by connecting the dots in a specific sequence, forming a series of joined line segments where each segment's endpoints are two consecutive dots in the sequence. A sequence of k dots is a valid unlock pattern if both of the following are true:

阅读全文 »

Leetcode 2021-12-07

341. Flatten Nested List Iterator (Medium)

You are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatten it.

阅读全文 »

Leetcode 2021-12-06

331. Verify Preorder Serialization of a Binary Tree

One way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as '#'.

阅读全文 »

Leetcode 2021-12-05

321. Create Maximum Number (Hard)

You are given two integer arrays nums1 and nums2 of lengths m and n respectively. nums1 and nums2 represent the digits of two numbers. You are also given an integer k.

阅读全文 »

Leetcode 2021-12-04

311. Sparse Matrix Multiplication (Medium)

Given two sparse matrices mat1 of size m x k and mat2 of size k x n, return the result of mat1 x mat2. You may assume that multiplication is always possible.

阅读全文 »