https://www.educative.io/api/edpresso/shot/5077575695073280/image/5192456339456000

Prerequisite: Singly Linked List in JavaScript


Photo by Hello I'm Nik 🎞 on Unsplash

Problem

Input: [-4,-1,0,3,10]
Output: [0,1,9,16,100]
Input: [-7,-3,2,3,11]
Output: [4,9,9,49,121]

Solution


Photo by Tingey Injury Law Firm on Unsplash

Problem

In a town, there are N people labelled from 1 to N.  There is a rumor that one of these people is secretly the town judge.If the town judge exists, then:1. The town judge trusts nobody.
2. Everybody (except for the town judge) trusts the town judge.
3. There is exactly one person that satisfies properties 1 and 2.
You are given trust, an array of pairs trust[i] = [a, b] representing that the person labelled a trusts the person labelled b.If the town judge exists and can be identified, return the label of the town judge…


Photo by Alla Hetman on Unsplash
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherwise, the NOT null node will be used as the node of new tree.


Photo by Greg Rosenke on Unsplash
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.Example 1:     3…


https://redux-saga.js.org/logo/0800/Redux-Saga-Logo-Landscape.png


Photo by Belinda Fewings on Unsplash

Problem:

Given a n-ary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).


JavaScript Solution of Trapping Rain Water
JavaScript Solution of Trapping Rain Water
Photo by Cristi Goia on Unsplash

Problem:

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.


Photo by Levi Jones on Unsplash


Example of Floyd’s algorithm

Gulgina Arkin

Multi-human-lingual and multi-programming-lingual | https://www.gaierken.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store