-
Given a 2 strings as input, write the function
indexOf(needle, haystack)
that returns the index of the first appearance of the first string (the needle) inside the second (the haystack). -
DO NOT USE built-in string methods like
indexOf()
,includes()
orsubstring()
You're an industrious programmer that lives off the grid. The local well that you use to fetch water has gone dry, so you've decided to collect rain water. Unfortunately, your collection device isn't flat.
Given n non-negative integers in an array representing an elevation map, compute how much rain water your collection device can hold. The width of each bar is 1.