stathat/consistent

GetN method may fall into infinite loop

power-more opened this issue · 0 comments

When I only have 2 elements, but execute Add 3 times, at this time c.count == 3, after that GetN(3) is executed, if start == 0, then the for loop will fall into an infinite loop, because i can never Return to 0, which means that the exit condition of start != i cannot be met, because the minimum value of i is 1, and len(res) is 2, which is always less than n, and the loop cannot exit.