Mark As Completed Discussion

One Pager Cheat Sheet

  • Write a method to return the frequency of the highest value in a 2D matrix array, which is initially prefilled with 0s, where the size of the array is m rows and n columns, and given a list of increment operations in the form of a two-number array [row, column].
  • Given the operations [1,1] and then [2,2] on a blank state of all 0s, we obtain a modified state of 2s.
  • The largest number in the upper left of the matrix was incremented by 1 due to the overlap of the two operations.
  • The cells with the greatest numbers can be found by looking at the edges of the range of each operation, as these are guaranteed to be layered over the most, with O(n) complexity.

This is our final solution.

To visualize the solution and step through the below code, click Visualize the Solution on the right-side menu or the VISUALIZE button in Interactive Mode.

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

You're doing a wonderful job. Keep going!

If you had any problems with this tutorial, check out the main forum thread here.