Skip to content

Bug Report for reverse-integer #4781

@harithagmu

Description

@harithagmu

Bug Report for https://neetcode.io/problems/reverse-integer

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

A minor bug in the reverse Integer problem from Neetcode150 Bit manipulation-

In solution 3.Iteration the following line doesn't correctly compare the MIN bound for negative values

if res < MIN // 10 or (res == MIN // 10 and digit < MIN % 10):
return 0

Test case failing: x=-9463847412

Corrected code should instead be:

if (res < int(MIN/10)) or (res == int(MIN/10) and digit < int(math.fmod(MIN, 10))):
return 0

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