The non-overlapping-same-row calculation is only correct if you have track 1 and track 2 non-overlapping but not for multiple tracks on the same row. Imagine you have n = 1, m = 7, k = 3 (all on row 1): track 1 at [1,3], track 2 at [5,6] and track 3 at [6,7] then we incorrectly calculate the result = 0 lamps. We should be able to place a lamp at pos 4. Somehow HackerRank only has test case with maximum 2 tracks on the same row or 3 tracks but they are completely non-overlapping. I love the thought process and the use of dictionary anw, thanks for this!
the solution does not account for when an overlap can occur where c1 is smaller than the current c1 stored in d it also does not account if there is no overlap but there is a train track that is before the one in the same row if that was already calculated You are lucky hackerank has bad test cases!
@@HackersRealm can u please guide me like i think of approcahes but when i implement it it throws errors so how should i think like how to develop approaches