TopCoder problem "ReversedSum" used in SRM 417 (Division II Level One)



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

0)
    
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.
1)
    
111
111
Returns: 222
2)
    
5
5
Returns: 1
3)
    
1000
1
Returns: 2
4)
    
456
789
Returns: 1461

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=9925

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13508&pm=9925

Writer:

Pawa

Testers:

PabloGilberto , Olexiy , ivan_metelsky , Xixas

Problem categories:

Simple Math