Bug Report for https://neetcode.io/problems/dynamicArray
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Below is the popback() method written in the solution of the problem. The method makes sure that self.length doesn't go out of bounds (becomes -ve).

In my attempt, I didn't check for that and allowed self.size (equivalent to self.length) to have negative values(that was error on my part) and my submission was successful.

I believe you guys need to add test cases to cover this bad behavior.
Below is my complete code:
class DynamicArray:
def __init__(self, capacity: int):
self.array = [None]*capacity
self.capacity = capacity
self.size = 0
def get(self, i: int) -> int:
return self.array[i]
def set(self, i: int, n: int) -> None:
self.array[i] = n
def pushback(self, n: int) -> None:
if self.size == self.capacity:
self.resize()
self.array[self.size] = n
self.size += 1
def popback(self) -> int:
self.size -= 1
el = self.array[self.size]
return el
def resize(self) -> None:
self.capacity *= 2
new_arr = [None] * self.capacity
for i in range(self.size):
new_arr[i] = self.array[i]
self.array = new_arr
def getSize(self) -> int:
return self.size
def getCapacity(self) -> int:
return self.capacity
Bug Report for https://neetcode.io/problems/dynamicArray
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Below is the

popback()method written in the solution of the problem. The method makes sure thatself.lengthdoesn't go out of bounds (becomes -ve).In my attempt, I didn't check for that and allowed

self.size(equivalent toself.length) to have negative values(that was error on my part) and my submission was successful.I believe you guys need to add test cases to cover this bad behavior.
Below is my complete code: