+ 1
Why it is showing illegal character Exception
12 Respostas
+ 1
🎶💞Sravs💞🥀
Here is correct solution.
Use Math.pow instead of 2 ^ i
https://code.sololearn.com/cRTSgBWBB0BO/?ref=app
+ 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
+ 1
It should be like this
Input :
3
1,2,3
Output:
11
Expl(2^0*3+2^1*2+2^3*1 = 11)
+ 1
Tq bhai
+ 1
But you changed nextLine() to next() why ?
Can you explain it clearly
0
No, I wrote it myself
0
🎶💞Sravs💞🥀
The code, you have written is giving wrong output
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?
0
Bhai, once check the code is it right or wrong for given constrinta
0
It should be like this
Input :
3
1,2,3
Output:
11
Expl(2^0*3+2^1*2+2^3*1 = 11)
0
🎶💞Sravs💞🥀
Because in nextLine() cursor move to next line so it also read empty value with original value
0
🎶💞Sravs💞🥀
In Java ^ use for different purpose. It is not actually same like in mathematics. So never use to get power value.