Fix: NumberFormatException with non-ASCII Unicode digits in MyAtoi (#7231)

Fix myAtoi handling of non-ASCII Unicode digits
This commit is contained in:
Mohammed Vijahath
2026-01-22 21:39:23 +05:30
committed by GitHub
parent 0f9139dc42
commit a7eeee2b5b

View File

@@ -45,7 +45,9 @@ public final class MyAtoi {
int number = 0;
while (index < length) {
char ch = s.charAt(index);
if (!Character.isDigit(ch)) {
// Accept only ASCII digits
if (ch < '0' || ch > '9') {
break;
}