LEARNING JOURNAL

I created this learning journal to practice writting and to help me learn by writting everything down. Source code here

2/2/2024

Flatten 2D Vector #3rd attempt

**This is my third attempt at solving this problem.

Let me try to explain what this code does.

Actually, this colI and rowI pointers are pointing to the next element. Because the function next return the next value, we make it return the value at rowI and colI. Then, we move the pointers to the next element.

We do that by increase coilI 1 unit. We left it there so that on the next call, the function hasNext is called to check if colI reaches the end of the current vector or not. If it does, move to the next available vector.

Why do we need to move the pointers to the next vector on hasNext? The reason is that hasNext needs to check whether or not the next vectors are empty before return true or false.

**