1514. Path with Maximum Probability

1514. Path with Maximum Probability You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the nodes a and b with a probability of success of traversing that edge succProb[i]. Given two nodes start and end, find the path with the maximum probability of success to go from start to end and return its success probability....

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

1306. Jump Game III

1306. Jump Game III Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach to any index with value 0. Notice that you can not jump outside of the array at any time. 1 2 3 4 5 6 7 8 Example 1: Input: arr = [4,2,3,0,3,1,2], start = 5 Output: true Explanation: All possible ways to reach at index 3 with value 0 are: index 5 -> index 4 -> index 1 -> index 3 index 5 -> index 6 -> index 4 -> index 1 -> index 3 1 2 3 4 5 6 7 Example 2: Input: arr = [4,2,3,0,3,1,2], start = 0 Output: true Explanation: One possible way to reach at index 3 with value 0 is: index 0 -> index 4 -> index 1 -> index 3 1 2 3 4 5 Example 3: Input: arr = [3,0,2,1,2], start = 2 Output: false Explanation: There is no way to reach at index 1 with value 0....

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

1584. Min Cost to Connect All Points

1584. Min Cost to Connect All Points You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi]. The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val. Return the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points....

<span title='2021-04-06 00:00:00 +0000 UTC'>April 6, 2021</span>&nbsp;·&nbsp;3 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

1387. Sort Integers by The Power Value

1387. Sort Integers by The Power Value The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps: if x is even then x = x / 2 if x is odd then x = 3 * x + 1 For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 –> 10 –> 5 –> 16 –> 8 –> 4 –> 2 –> 1)....

<span title='2021-04-03 00:00:00 +0000 UTC'>April 3, 2021</span>&nbsp;·&nbsp;3 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

1814. Count Nice Pairs in an Array

1814. Count Nice Pairs in an Array You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair of indices (i, j) is nice if it satisfies all of the following conditions: 0 <= i < j < nums.length nums[i] + rev(nums[j]) == nums[j] + rev(nums[i]) Return the number of nice pairs of indices....

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

563. Binary Tree Tilt

563. Binary Tree Tilt Given the root of a binary tree, return the sum of every tree node’s tilt. The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right subtree node values. If a node does not have a left child, then the sum of the left subtree node values is treated as 0. The rule is similar if there the node does not have a right child....

<span title='2021-04-02 00:00:00 +0000 UTC'>April 2, 2021</span>&nbsp;·&nbsp;3 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

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

Regions Cut By Slashes

An a N x N grid composed of 1 x 1 squares, each 1 x 1 square consists of a /, , or blank space. These characters divide the square into contiguous regions. (Note that backslash characters are escaped, so a \ is represented as “\”.) Return the number of regions. Example 1: 1 2 3 4 5 6 7 Input: [ " /", "/ " ] Output: 2 Explanation: The 2x2 grid is as follows: Example 2:...

<span title='2020-11-08 00:00:00 +0000 UTC'>November 8, 2020</span>&nbsp;·&nbsp;7 min&nbsp;·&nbsp;volyx