+ 1

Why it is showing illegal character Exception

https://code.sololearn.com/cpTywSl4eglV/?ref=app

15th Apr 2021, 3:53 PM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
12 ответов
+ 1
🎶💞Sravs💞🥀 Here is correct solution. Use Math.pow instead of 2 ^ i https://code.sololearn.com/cRTSgBWBB0BO/?ref=app
16th Apr 2021, 3:23 AM
A͢J
A͢J - avatar
+ 1
🎶💞Sravs💞🥀 Did you copy code from somewhere? There is extra characters after this line Arrays.sort(arr); Use next () instead of nextLine() https://code.sololearn.com/cXyqJu5Z3lzi/?ref=app
15th Apr 2021, 5:14 PM
A͢J
A͢J - avatar
+ 1
It should be like this Input : 3 1,2,3 Output: 11 Expl(2^0*3+2^1*2+2^3*1 = 11)
16th Apr 2021, 3:14 AM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
+ 1
Tq bhai
16th Apr 2021, 3:27 AM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
+ 1
But you changed nextLine() to next() why ? Can you explain it clearly
16th Apr 2021, 3:28 AM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
0
No, I wrote it myself
16th Apr 2021, 3:10 AM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
0
🎶💞Sravs💞🥀 The code, you have written is giving wrong output
16th Apr 2021, 3:13 AM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
0
🎶💞Sravs💞🥀 I didn't change anything in your logic. I just removed extra character and did change in string input. What you want exactly?
16th Apr 2021, 3:15 AM
A͢J
A͢J - avatar
0
Bhai, once check the code is it right or wrong for given constrinta
16th Apr 2021, 3:20 AM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
0
It should be like this Input : 3 1,2,3 Output: 11 Expl(2^0*3+2^1*2+2^3*1 = 11)
16th Apr 2021, 3:20 AM
🎶💞Sravs💞🥀
🎶💞Sravs💞🥀 - avatar
0
🎶💞Sravs💞🥀 Because in nextLine() cursor move to next line so it also read empty value with original value
16th Apr 2021, 3:40 AM
A͢J
A͢J - avatar
0
🎶💞Sravs💞🥀 In Java ^ use for different purpose. It is not actually same like in mathematics. So never use to get power value.
16th Apr 2021, 3:42 AM
A͢J
A͢J - avatar