We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
In java 8, with a return type of int, some of the test cases return impossible values.
For example, in test case 'input11.txt' the first line is stated to return 4999350028.
This is an impossible value in java 8 for an int (a compiler would complain .. 'The literal 4999350028 of type int is out of range' )
(aside: How is the test even running in java 8?)
The actual value returned wraps the int - and hence fails the test.
Redefining the return type to long would give the correct answer, but fails to compile.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
String Similarity
You are viewing a single comment's thread. Return to all comments →
In java 8, with a return type of int, some of the test cases return impossible values. For example, in test case 'input11.txt' the first line is stated to return 4999350028. This is an impossible value in java 8 for an int (a compiler would complain .. 'The literal 4999350028 of type int is out of range' ) (aside: How is the test even running in java 8?) The actual value returned wraps the int - and hence fails the test. Redefining the return type to long would give the correct answer, but fails to compile.