A data grid fills its rows as they load. rows holds the loaded row IDs first, followed only by null placeholders for rows that have not loaded yet, such as [8, 3, 5, null, null].
Write loadedCount(rows) that returns how many rows have loaded: the index of the first null, or rows.length if there is no null.
Most of the time only a few rows have loaded in a very long grid, so find the boundary by doubling an index from the start, then binary searching.
Input: rows = [8,3,5,null,null] Output: 3
Three rows have loaded before the first null.
Input: rows = [null,null,null] Output: 0
Nothing has loaded yet.
0 <= rows.length <= 100000null comes after every loaded row.Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #181 End of the Loaded Rows. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.