Skip to content

Bug Report for dynamicArray #4404

@RicoFio

Description

@RicoFio

Bug Report for https://neetcode.io/problems/dynamicArray

The sample solution implements:

    # Remove the last element in the array
    def popback(self) -> int:
        if self.length > 0:
            # soft delete the last element
            self.length -= 1
        # return the popped element
        return self.arr[self.length]

However, this is wrong. The element is not removed and can still be accessed by get. Thus, there should (a) be a test case that covers this to ensure that the implementation matches the requirements, and (b) the Python sample solution should use pop (or, at least, set the element to 0). The sample solutions can look something like:

    def popback(self) -> int:
        if self._length > 0:
            self._length -= 1

        return self._array.pop(self._length)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy