269. Alien Dictionary

There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you. You are given a list of strings words from the alien language’s dictionary, where the strings in words are sorted lexicographically by the rules of this new language. Return a string of the unique letters in the new alien language sorted in lexicographically increasing order by the new language’s rules....

<span title='2022-01-29 00:00:00 +0000 UTC'>January 29, 2022</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1136. Parallel Courses

You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCoursei, nextCoursei], representing a prerequisite relationship between course prevCoursei and course nextCoursei: course prevCoursei has to be taken before course nextCoursei. In one semester, you can take any number of courses as long as you have taken all the prerequisites in the previous semester for the courses you are taking....

<span title='2021-11-30 00:00:00 +0000 UTC'>November 30, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

332. Reconstruct Itinerary

You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it. All of the tickets belong to a man who departs from “JFK”, thus, the itinerary must begin with “JFK”. If there are multiple valid itineraries, you should return the itinerary that has the smallest lexical order when read as a single string....

<span title='2021-11-29 00:00:00 +0000 UTC'>November 29, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

655. Print Binary Tree

Given the root of a binary tree, construct a 0-indexed m x n string matrix res that represents a formatted layout of the tree. The formatted layout matrix should be constructed using the following rules: The height of the tree is height and the number of rows m should be equal to height + 1. The number of columns n should be equal to 2height+1 - 1. Place the root node in the middle of the top row (more formally, at location res[0][(n-1)/2])....

<span title='2021-11-29 00:00:00 +0000 UTC'>November 29, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

1168. Optimize Water Distribution in a Village

1168. Optimize Water Distribution in a Village There are n houses in a village. We want to supply water for all the houses by building wells and laying pipes. For each house i, we can either build a well inside it directly with cost wells[i - 1] (note the -1 due to 0-indexing), or pipe in water from another well to it. The costs to lay pipes between houses are given by the array pipes, where each pipes[j] = [house1j, house2j, costj] represents the cost to connect house1j and house2j together using a pipe....

<span title='2021-08-01 00:00:00 +0000 UTC'>August 1, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance

1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between cities fromi and toi, and given the integer distanceThreshold. Return the city with the smallest number of cities that are reachable through some path and whose distance is at most distanceThreshold, If there are multiple such cities, return the city with the greatest number....

<span title='2021-04-11 00:00:00 +0000 UTC'>April 11, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

1631. Path With Minimum Effort

1631. Path With Minimum Effort You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom-right cell, (rows-1, columns-1) (i.e., 0-indexed). You can move up, down, left, or right, and you wish to find a route that requires the minimum effort....

<span title='2021-04-11 00:00:00 +0000 UTC'>April 11, 2021</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;volyx

133. Clone Graph

133. Clone Graph Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors. 1 2 3 4 class Node { public int val; public List<Node> neighbors; } Test case format: For simplicity sake, each node’s value is the same as the node’s index (1-indexed). For example, the first node with val = 1, the second node with val = 2, and so on....

<span title='2021-04-09 00:00:00 +0000 UTC'>April 9, 2021</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;volyx

690. Employee Importance

690. Employee Importance You are given a data structure of employee information, which includes the employee’s unique id, their importance value and their direct subordinates’ id. For example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3. They have importance value 15, 10 and 5, respectively. Then employee 1 has a data structure like [1, 15, [2]], and employee 2 has [2, 10, [3]], and employee 3 has [3, 5, []]....

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

1557. Minimum Number of Vertices to Reach All Nodes

1557. Minimum Number of Vertices to Reach All Nodes Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge from node fromi to node toi. Find the smallest set of vertices from which all nodes in the graph are reachable. It’s guaranteed that a unique solution exists. Notice that you can return the vertices in any order....

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

1254. Number of Closed Islands

1254. Number of Closed Islands Given a 2D grid consists of 0s (land) and 1s (water). An island is a maximal 4-directionally connected group of 0s and a closed island is an island totally (all left, top, right, bottom) surrounded by 1s. Return the number of closed islands. 1 2 3 4 5 6 Example 1: Input: grid = [[1,1,1,1,1,1,1,0],[1,0,0,0,0,1,1,0],[1,0,1,0,1,1,1,0],[1,0,0,0,0,1,0,1],[1,1,1,1,1,1,1,0]] Output: 2 Explanation: Islands in gray are closed because they are completely surrounded by water (group of 1s)....

<span title='2021-04-01 00:00:00 +0000 UTC'>April 1, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

695. Max Area of Island

695. Max Area of Island Given a non-empty 2D array grid of 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. Find the maximum area of an island in the given 2D array. (If there is no island, the maximum area is 0.) 1 2 3 4 5 6 7 8 9 10 Example 1: [[0,0,1,0,0,0,0,1,0,0,0,0,0], [0,0,0,0,0,0,0,1,1,1,0,0,0], [0,1,1,0,1,0,0,0,0,0,0,0,0], [0,1,0,0,1,1,0,0,1,0,1,0,0], [0,1,0,0,1,1,0,0,1,1,1,0,0], [0,0,0,0,0,0,0,0,0,0,1,0,0], [0,0,0,0,0,0,0,1,1,1,0,0,0], [0,0,0,0,0,0,0,1,1,0,0,0,0]] Given the above grid, return 6....

<span title='2021-04-01 00:00:00 +0000 UTC'>April 1, 2021</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;volyx

1302. Deepest Leaves Sum

1302. Deepest Leaves Sum Given the root of a binary tree, return the sum of values of its deepest leaves. 1 2 3 4 Example 1: Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8] Output: 15 1 2 3 4 Example 2: Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5] Output: 19 Constraints: The number of nodes in the tree is in the range [1, 104]. 1 <= Node.val <= 100 Solution 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 /** * Definition for a binary tree node....

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

797. All Paths From Source to Target

797. All Paths From Source to Target Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1, and return them in any order. The graph is given as follows: graph[i] is a list of all nodes you can visit from node i (i.e., there is a directed edge from node i to node graph[i][j])....

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

207. Course Schedule

207. Course Schedule There are a total of n courses you have to take labelled from 0 to n - 1. Some courses may have prerequisites, for example, if prerequisites[i] = [ai, bi] this means you must take the course bi before the course ai. Given the total number of courses numCourses and a list of the prerequisite pairs, return the ordering of courses you should take to finish all courses....

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