You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| 0117 |[Populating Next Right Pointers in Each Node II](src/main/ts/g0101_0200/s0117_populating_next_right_pointers_in_each_node_ii/solution.ts)| Medium | Depth_First_Search, Breadth_First_Search, Tree, Binary_Tree, Linked_List | 47 | 97.74
1111
1114
| 0114 |[Flatten Binary Tree to Linked List](src/main/ts/g0101_0200/s0114_flatten_binary_tree_to_linked_list/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Stack, Linked_List, Big_O_Time_O(N)_Space_O(N) | 0 | 100.00
| 0129 |[Sum Root to Leaf Numbers](src/main/ts/g0101_0200/s0129_sum_root_to_leaf_numbers/solution.ts)| Medium | Depth_First_Search, Tree, Binary_Tree | 0 | 100.00
1113
1117
| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11
1114
1118
| 0236 |[Lowest Common Ancestor of a Binary Tree](src/main/ts/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/solution.ts)| Medium | Top_100_Liked_Questions, Depth_First_Search, Tree, Binary_Tree, Big_O_Time_O(n)_Space_O(n) | 61 | 75.97
| 0124 |[Binary Tree Maximum Path Sum](src/main/ts/g0101_0200/s0124_binary_tree_maximum_path_sum/solution.ts)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Depth_First_Search, Tree, Binary_Tree, Udemy_Tree_Stack_Queue, Top_Interview_150_Binary_Tree_General, Big_O_Time_O(N)_Space_O(N) | 2 | 71.11
1722
1733
| 0123 |[Best Time to Buy and Sell Stock III](src/main/ts/g0101_0200/s0123_best_time_to_buy_and_sell_stock_iii/solution.ts)| Hard | Array, Dynamic_Programming, Top_Interview_150_Multidimensional_DP | 5 | 85.07
A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words <code>beginWord -> s<sub>1</sub> -> s<sub>2</sub> -> ... -> s<sub>k</sub></code> such that:
6
+
7
+
* Every adjacent pair of words differs by a single letter.
8
+
* Every <code>s<sub>i</sub></code> for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need to be in `wordList`.
9
+
* <code>s<sub>k</sub> == endWord</code>
10
+
11
+
Given two words, `beginWord` and `endWord`, and a dictionary `wordList`, return _the **number of words** in the **shortest transformation sequence** from_`beginWord`_to_`endWord`_, or_`0`_if no such sequence exists._
**Explanation:** The root-to-leaf path `1->2` represents the number `12`. The root-to-leaf path `1->3` represents the number `13`. Therefore, sum = 12 + 13 = `25`.
**Explanation:** The root-to-leaf path `4->9->5` represents the number 495. The root-to-leaf path `4->9->1` represents the number 491. The root-to-leaf path `4->0` represents the number 40. Therefore, sum = 495 + 491 + 40 = `1026`.
34
+
35
+
**Constraints:**
36
+
37
+
* The number of nodes in the tree is in the range `[1, 1000]`.
There are `n` gas stations along a circular route, where the amount of gas at the <code>i<sup>th</sup></code> station is `gas[i]`.
6
+
7
+
You have a car with an unlimited gas tank and it costs `cost[i]` of gas to travel from the <code>i<sup>th</sup></code> station to its next <code>(i + 1)<sup>th</sup></code> station. You begin the journey with an empty tank at one of the gas stations.
8
+
9
+
Given two integer arrays `gas` and `cost`, return _the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return_`-1`. If there exists a solution, it is **guaranteed** to be **unique**
10
+
11
+
**Example 1:**
12
+
13
+
**Input:** gas = [1,2,3,4,5], cost = [3,4,5,1,2]
14
+
15
+
**Output:** 3
16
+
17
+
**Explanation:**
18
+
19
+
Start at station 3 (index 3) and fill up with 4 unit of gas. Your tank = 0 + 4 = 4
20
+
Travel to station 4. Your tank = 4 - 1 + 5 = 8
21
+
Travel to station 0. Your tank = 8 - 2 + 1 = 7
22
+
Travel to station 1. Your tank = 7 - 3 + 2 = 6
23
+
Travel to station 2. Your tank = 6 - 4 + 3 = 5
24
+
Travel to station 3. The cost is 5. Your gas is just enough to travel back to station 3.
25
+
Therefore, return 3 as the starting index.
26
+
27
+
**Example 2:**
28
+
29
+
**Input:** gas = [2,3,4], cost = [3,4,3]
30
+
31
+
**Output:** -1
32
+
33
+
**Explanation:**
34
+
35
+
You can't start at station 0 or 1, as there is not enough gas to travel to the next station.
36
+
Let's start at station 2 and fill up with 4 unit of gas. Your tank = 0 + 4 = 4
37
+
Travel to station 0. Your tank = 4 - 3 + 2 = 3
38
+
Travel to station 1. Your tank = 3 - 3 + 3 = 3
39
+
You cannot travel back to station 2, as it requires 4 unit of gas but you only have 3.
40
+
Therefore, you can't travel around the circuit once no matter where you start.
There are `n` children standing in a line. Each child is assigned a rating value given in the integer array `ratings`.
6
+
7
+
You are giving candies to these children subjected to the following requirements:
8
+
9
+
* Each child must have at least one candy.
10
+
* Children with a higher rating get more candies than their neighbors.
11
+
12
+
Return _the minimum number of candies you need to have to distribute the candies to the children_.
13
+
14
+
**Example 1:**
15
+
16
+
**Input:** ratings = [1,0,2]
17
+
18
+
**Output:** 5
19
+
20
+
**Explanation:** You can allocate to the first, second and third child with 2, 1, 2 candies respectively.
21
+
22
+
**Example 2:**
23
+
24
+
**Input:** ratings = [1,2,2]
25
+
26
+
**Output:** 4
27
+
28
+
**Explanation:** You can allocate to the first, second and third child with 1, 2, 1 candies respectively. The third child gets 1 candy because it satisfies the above two conditions.
Given an integer array `nums` where every element appears **three times** except for one, which appears **exactly once**. _Find the single element and return it_.
6
+
7
+
You must implement a solution with a linear runtime complexity and use only constant extra space.
0 commit comments