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

451. Sort Characters By Frequency

![https://leetcode.com/problems/sort-characters-by-frequency/] Given a string, sort it in decreasing order based on the frequency of characters. 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 Example 1: Input: "tree" Output: "eert" Explanation: 'e' appears twice while 'r' and 't' both appear once. So 'e' must appear before both 'r' and 't'....

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

767. Reorganize String

Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same. If possible, output any possible result. If not possible, return the empty string. 1 2 3 4 5 6 7 8 9 Example 1: Input: S = "aab" Output: "aba" Example 2: Input: S = "aaab" Output: "" Note: S will consist of lowercase letters and have length in range [1, 500]....

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

1046. Last Stone Weight

![https://leetcode.com/problems/last-stone-weight/] We have a collection of stones, each stone has a positive integer weight. Each turn, we choose the two heaviest stones and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is: If x == y, both stones are totally destroyed; If x != y, the stone of weight x is totally destroyed, and the stone of weight y has new weight y-x....

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

215. Kth Largest Element in an Array

![https://leetcode.com/problems/kth-largest-element-in-an-array/] Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. 1 2 3 4 5 6 7 8 9 10 11 12 Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example 2: Input: [3,2,3,1,2,4,5,5,6] and k = 4 Output: 4 Note: You may assume k is always valid, 1 ≤ k ≤ array's length....

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

347. Top K Frequent Elements

![https://leetcode.com/problems/top-k-frequent-elements/] Given a non-empty array of integers, return the k most frequent elements. 1 2 3 4 5 6 7 8 9 Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input: nums = [1], k = 1 Output: [1] Note: You may assume k is always valid, 1 ≤ k ≤ number of unique elements. Your algorithm’s time complexity must be better than O(n log n), where n is the array’s size....

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

378. Kth Smallest Element in a Sorted Matrix

![https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/] Given an n x n matrix where each of the rows and columns are sorted in ascending order, return the kth smallest element in the matrix. Note that it is the kth smallest element in the sorted order, not the kth distinct element. 1 2 3 4 5 6 7 8 9 10 Example 1: Input: matrix = [[1,5,9],[10,11,13],[12,13,15]], k = 8 Output: 13 Explanation: The elements in the matrix are [1,5,9,10,11,12,13,13,15], and the 8th smallest number is 13 Example 2: Input: matrix = [[-5]], k = 1 Output: -5 Constraints:...

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

57. Insert Interval

![https://leetcode.com/problems/insert-interval/] Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. 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 Example 1: Input: intervals = [[1,3],[6,9]], newInterval = [2,5] Output: [[1,5],[6,9]] Example 2: Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8] Output: [[1,2],[3,10],[12,16]] Explanation: Because the new interval [4,8] overlaps with [3,5],[6,7],[8,10]....

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

1329. Sort the Matrix Diagonally

![https://leetcode.com/problems/sort-the-matrix-diagonally/] A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix’s end. For example, the matrix diagonal starting from mat[2][0], where mat is a 6 x 3 matrix, includes cells mat[2][0], mat[3][1], and mat[4][2]. Given an m x n matrix mat of integers, sort each matrix diagonal in ascending order and return the resulting matrix....

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

75. Sort Colors

![https://leetcode.com/problems/sort-colors/] Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Example 1: Input: nums = [2,0,2,1,1,0] Output: [0,0,1,1,2,2] Example 2: Input: nums = [2,0,1] Output: [0,1,2] Example 3: Input: nums = [0] Output: [0] Example 4: Input: nums = [1] Output: [1] Constraints:...

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

56. Merge Intervals

![https://leetcode.com/problems/merge-intervals/] Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. 1 2 3 4 5 6 7 8 9 10 11 Example 1: Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Input: intervals = [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] and [4,5] are considered overlapping....

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