Description
https://leetcode.com/problems/closest-binary-search-tree-value-ii/description/
Solution
1 | /** |
Why don't you come to your senses?
https://leetcode.com/problems/closest-binary-search-tree-value-ii/description/
1 | /** |
Design a hit counter which counts the number of hits received in the past 5 minutes.
Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being made to the system in chronological order (ie, the timestamp is monotonically increasing). You may assume that the earliest timestamp starts at 1.
It is possible that several hits arrive roughly at the same time.
Example:
1 | HitCounter counter = new HitCounter(); |
1 | #define RANGE 300 |
https://leetcode.com/problems/robot-room-cleaner/description/
1 | /** |
https://leetcode.com/problems/employee-free-time/description/
1 | /** |
Given a binary tree, return the vertical order traversal of its nodes’ values. (ie, from top to bottom, column by column).
If two nodes are in the same row and column, the order should be from left to right.
Examples 1:
1 | Input: [3,9,20,null,null,15,7] |
Examples 2:
1 | Input: [3,9,8,4,0,1,7] |
Examples 3:
1 | Input: [3,9,8,4,0,1,7,null,null,null,2,5] (0's right child is 2 and 1's left child is 5) |
1 | /** |
Given a nested list of integers, return the sum of all integers in the list weighted by their depth.
Each element is either an integer, or a list – whose elements may also be integers or other lists.
Different from the previous question where weight is increasing from root to leaf, now the weight is defined from bottom up. i.e., the leaf level integers have weight 1, and the root level integers have the largest weight.
Example 1:
1 | Input: [[1,1],2,[1,1]] |
Example 2:
1 | Input: [1,[4,[6]]] |
1 | /** |
https://leetcode.com/problems/inorder-successor-in-bst/
1 | /** |
1 | /** |
https://leetcode.com/problems/design-snake-game/description/
1 | class SnakeGame { |
https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/description/
1 | class Solution { |
Design a Tic-tac-toe game that is played between two players on a n x n grid.
You may assume the following rules:
Example:
1 | Given n = 3, assume that player 1 is "X" and player 2 is "O" in the board. |
Follow up:
Could you do better than O(n2) per move()
operation?
1 | class TicTacToe { |