The problem of the Day

LeetCode + GeeksforGeeks { 12–09–2021 }

Akash Singh
2 min readSep 12, 2021

--

Reachable Nodes In Subdivided Graph

Example 1:

Input: edges = [[0,1,10],[0,2,1],[1,2,2]], maxMoves = 6, n = 3
Output: 13
Explanation: The edge subdivisions are shown in the image above.
The nodes that are reachable are highlighted in yellow.

Example 2:

Input: edges = [[0,1,4],[1,2,6],[0,2,8],[1,3,1]], maxMoves = 10, n = 4
Output: 23

Example 3:

Input: edges = [[1,2,4],[1,4,5],[1,3,1],[2,3,4],[3,4,5]], maxMoves = 17, n = 5
Output: 1
Explanation: Node 0 is disconnected from the rest of the graph, so only node 0 is reachable.

CODE →

Right Most non Zero Digit

Example 1:

Input:
N = 4, A = {3, 23, 30, 45}
Output:
5
Explanation:
Product of these numbers
are 93150.Rightmost
non-zero digit is 5.

Example 2:

Input:
N = 5, A = {1, 2, 3, 4, 5}
Output:
2
Explanation:
Product of these numbers
are 120. Rightmost
non-zero digit is 2.

CODE →

Don’t forget to give us your 👏 !

--

--