Problem:
Given the number N, print reverse of number N. Note: do not print leading zeros in output.
For example N = 100, Reverse will be 1, not 001
input: input contains a single integer N.
Output: print reverse of integer N.
Constraints:
1<=N<=10_000
Solution:
First reverse the integer, you can do this in various ways, but the easiest would be to transform it into a string, then reverse the string.
Lex x be the integer you want to reverse.
String reversed = new StringBuilder().append(x).reverse().toString();
System.out.println(reversed);
Since the question asks for no leading zeros you can get that desired output by putting the reversed value back into an integer like so:
Integer.parseInt(reversed);
Make sure to comment below if this was helpful to you. See you next time.