max_so_far
to track the maximum value encountered so far.chunk_count
to count the number of chunks.arr
using an index i
.
a. Update max_so_far
to be the maximum of max_so_far
and arr[i]
.
b. If max_so_far
is equal to i
, increment chunk_count
.chunk_count
as the maximum number of chunks.