Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 91ca25b

Browse files
committed
Check parseLong
1 parent 1d8b3ae commit 91ca25b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/com/hackerrank/algorithms/recursion/RecursiveDigitSum.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ private static int superDigit(String n, int k) {
3434
Long sum = 0L;
3535
char[] num = n.toCharArray();
3636
for (int i = 0; i < num.length; i++) {
37-
sum += Long.parseLong(String.valueOf(num[i]));
37+
try {
38+
sum += Long.parseLong(String.valueOf(num[i]));
39+
} catch(Exception ex) {
40+
throw new Exception("by input exception [" + n + "]");
41+
}
3842
}
3943

4044
if (k != 0) sum *= k;

0 commit comments

Comments
 (0)