199. Binary Tree Right Side View

199. Binary Tree Right Side View Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. 1 2 3 4 Example 1: Input: root = [1,2,3,null,5,null,4] Output: [1,3,4] 1 2 3 4 Example 2: Input: root = [1,null,3] Output: [1,3] 1 2 3 4 Example 3: Input: root = [] Output: [] Constraints:...

<span title='2021-03-27 00:00:00 +0000 UTC'>March 27, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

102. Binary Tree Level Order Traversal

107. Binary Tree Level Order Traversal II Given the root of a binary tree, return the bottom-up level order traversal of its nodes’ values. (i.e., from left to right, level by level from leaf to root). 1 2 3 4 Example 1: Input: root = [3,9,20,null,null,15,7] Output: [[15,7],[9,20],[3]] 1 2 3 4 Example 2: Input: root = [1] Output: [[1]] 1 2 3 4 Example 3: Input: root = [] Output: [] Constraints:...

<span title='2021-03-26 00:00:00 +0000 UTC'>March 26, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

102. Binary Tree Level Order Traversal

102. Binary Tree Level Order Traversal Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level). 1 2 3 4 Example 1: Input: root = [3,9,20,null,null,15,7] Output: [[3],[9,20],[15,7]] 1 2 3 4 Example 2: Input: root = [1] Output: [[1]] 1 2 3 4 Example 3: Input: root = [] Output: [] Constraints: The number of nodes in the tree is in the range [0, 2000]....

<span title='2021-03-26 00:00:00 +0000 UTC'>March 26, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

743. Network Delay Time

743. Network Delay Time You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is the source node, vi is the target node, and wi is the time it takes for a signal to travel from source to target. We will send a signal from a given node k....

<span title='2021-03-25 00:00:00 +0000 UTC'>March 25, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

787. Cheapest Flights Within K Stops

787. Cheapest Flights Within K Stops There are n cities connected by m flights. Each flight starts from city u and arrives at v with a price w. Now given all the cities and flights, together with starting city src and the destination dst, your task is to find the cheapest price from src to dst with up to k stops. If there is no such route, output -1. 1 2 3 4 5 6 7 Example 1: Input: n = 3, edges = [[0,1,100],[1,2,100],[0,2,500]] src = 0, dst = 2, k = 1 Output: 200 Explanation: The graph looks like this: The cheapest price from city 0 to city 2 with at most 1 stop costs 200, as marked red in the picture....

<span title='2021-03-24 00:00:00 +0000 UTC'>March 24, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

105. Construct Binary Tree from Preorder and Inorder Traversal

105. Construct Binary Tree from Preorder and Inorder Traversal Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree. 1 2 3 4 Example 1: Input: preorder = [3,9,20,15,7], inorder = [9,3,15,20,7] Output: [3,9,20,null,null,15,7] 1 2 3 4 Example 2: Input: preorder = [-1], inorder = [-1] Output: [-1] Constraints:...

<span title='2021-03-23 00:00:00 +0000 UTC'>March 23, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

145. Binary Tree Postorder Traversal

145. Binary Tree Postorder Traversal Given the root of a binary tree, return the postorder traversal of its nodes’ values. 1 2 3 4 Example 1: Input: root = [1,null,2,3] Output: [3,2,1] 1 2 3 4 Example 2: Input: root = [] Output: [] 1 2 3 4 Example 3: Input: root = [1] Output: [1] 1 2 3 4 Example 4: Input: root = [1,2] Output: [2,1] 1 2 3 4 Example 5: Input: root = [1,null,2] Output: [2,1] Constraints:...

<span title='2021-03-22 00:00:00 +0000 UTC'>March 22, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

94. Binary Tree Inorder Traversal

94. Binary Tree Inorder Traversal Given the root of a binary tree, return the inorder traversal of its nodes’ values. 1 2 3 4 Example 1: Input: root = [1,null,2,3] Output: [1,3,2] 1 2 3 4 Example 2: Input: root = [] Output: [] 1 2 3 4 Example 3: Input: root = [1] Output: [1] 1 2 3 4 Example 4: Input: root = [1,2] Output: [2,1] 1 2 3 4 Example 5: Input: root = [1,null,2] Output: [1,2] Constraints:...

<span title='2021-03-22 00:00:00 +0000 UTC'>March 22, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

144. Binary Tree Preorder Traversal

144. Binary Tree Preorder Traversal Given the root of a binary tree, return the preorder traversal of its nodes’ values. 1 2 3 4 Example 1: Input: root = [1,null,2,3] Output: [1,2,3] 1 2 3 4 Example 2: Input: root = [] Output: [] 1 2 3 4 Example 3: Input: root = [1] Output: [1] 1 2 3 4 Example 4: Input: root = [1,2] Output: [1,2] 1 2 3 4 Example 5: Input: root = [1,null,2] Output: [1,2] Constraints:...

<span title='2021-03-16 00:00:00 +0000 UTC'>March 16, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

149. Max Points on a Line

149. Max Points on a Line Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line. 1 2 3 4 Example 1: Input: points = [[1,1],[2,2],[3,3]] Output: 3 1 2 3 4 Example 2: Input: points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]] Output: 4 Constraints: 1 <= points.length <= 300 points[i].length == 2 -104 <= xi, yi <= 104 All the points are unique....

<span title='2021-03-16 00:00:00 +0000 UTC'>March 16, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

108. Convert Sorted Array to Binary Search Tree

108. Convert Sorted Array to Binary Search Tree Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. A height-balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one. 1 2 3 4 5 Example 1: Input: nums = [-10,-3,0,5,9] Output: [0,-3,9,-10,null,5] Explanation: [0,-10,5,null,-3,null,9] is also accepted: 1 2 3 4 5 Example 2: Input: nums = [1,3] Output: [3,1] Explanation: [1,3] and [3,1] are both a height-balanced BSTs....

<span title='2021-03-13 00:00:00 +0000 UTC'>March 13, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

110. Balanced Binary Tree

110. Balanced Binary Tree Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the left and right subtrees of every node differ in height by no more than 1. 1 2 3 4 Example 1: Input: root = [3,9,20,null,null,15,7] Output: true 1 2 3 4 Example 2: Input: root = [1,2,2,3,3,null,null,4,4] Output: false 1 2 3 4 Example 3: Input: root = [] Output: true Constraints:...

<span title='2021-03-13 00:00:00 +0000 UTC'>March 13, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

111. Minimum Depth of Binary Tree

111. Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no children. 1 2 3 4 Example 1: Input: root = [3,9,20,null,null,15,7] Output: 2 1 2 3 4 Example 2: Input: root = [2,null,3,null,4,null,5,null,6] Output: 5 Constraints:...

<span title='2021-03-12 00:00:00 +0000 UTC'>March 12, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

100. Same Tree

![https://leetcode.com/problems/same-tree/] Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the same value. 1 2 3 4 Example 1: Input: p = [1,2,3], q = [1,2,3] Output: true 1 2 3 4 Example 2: Input: p = [1,2], q = [1,null,2] Output: false 1 2 3 4 Example 3: Input: p = [1,2,1], q = [1,1,2] Output: false Constraints:...

<span title='2021-03-11 00:00:00 +0000 UTC'>March 11, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

101. Symmetric Tree

!()[https://leetcode.com/problems/symmetric-tree/] Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). 1 2 3 4 Example 1: Input: root = [1,2,2,3,4,4,3] Output: true 1 2 3 4 Example 2: Input: root = [1,2,2,null,3,null,3] Output: false Constraints: The number of nodes in the tree is in the range [1, 1000]. -100 <= Node.val <= 100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 /** * Definition for a binary tree node....

<span title='2021-03-11 00:00:00 +0000 UTC'>March 11, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx