Problem Statement
For a given positive integer X we can obtain the reversed positive integer Rev(X) by reversing the order of X's digits and removing leading zeroes. For example, if X = 123 then Rev(X) = 321; and if X = 100, then Rev(X) = 1.
You will be given two positive integers x and y. Return their reversed sum, which is defined as Rev(Rev(x) + Rev(y)).
Definition
- Class:
- ReversedSum
- Method:
- getReversedSum
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int getReversedSum(int x, int y)
- (be sure your method is public)
Constraints
- x and y will each be between 1 and 1000, inclusive.
Examples
123
100
Returns: 223
As mentioned in the problem statement, Rev(123) = 321 and Rev(100) = 1. So, the reversed sum is equal to Rev(322) = 223.111
111
Returns: 222
5
5
Returns: 1
1000
1
Returns: 2
456
789
Returns: 1461