Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class VMwareOA {
- public static int distance(int a, int b) {
- int res = 0;
- while (a > 0 && b > 0) {
- res += Math.abs(a % 10 - b % 10);
- a /= 10;
- b /= 10;
- }
- return res;
- }
- public static void main(String[] args) {
- // Testcase1: 3
- System.out.println(distance(133,343));
- // Testcase2: 4
- System.out.println(distance(1234,1221));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement