Problem 1 -> rainWater.js

We have a 2 dimension elevation map, represented by an array, where each element represents the height of the Xi coordinate. Calculate how much water can be trapped in the valleys if it starts to rain.

Example:

● Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] ● Output: 6

Exercise Write a command line program (Node, PHP) that given an array of integers as an argument returns the correct answer. The input will be provided as a comma separated list of integers: 1,34,5,1.

Command line execution

node rainWater.js

Problem 2 -> mergedLists.js

We have a collection of linked lists. Each linked list contains integers in ascending order. We need to merge all linked lists into a single sorted linked list.

Example:

Input: [[1->4->5],[1->3->4],[2->6]] Output: [1->1->2->3->4->4->5->6] Exercise Write a command line program (Node, PHP) that given an input returns the correct answer. The format of the inputs and outputs is not specified and the solution must propose one.

Command line execution

node mergedLists.js