Amdocs Coding Question | Reverse Number | Palindrome

Hello friends, I hope you all are doing great. In this post today we will learn to solve the  coding questions which is being asked by the Amdocs company recently. If you are preparing for selection in any company then this post will help you definitely.

Lets Start

Click here to get All Company Coding + Interview Questions and Programs All Coding Programs

1.Reverse Number / Palindrome

Please implement the function isReverseNumber to check if a given positive number equals to the same number reversed.

Examples:

Given a number 5005

The function should return true, since the reversed version of 5005 is 5005.

Example :-

  • Input:
    • 51215
  • Output:
    • true

Explanation:-

Since the reversed version of 51215 is 51215 so the output will be true.

Code in Python

#Code in Python
class TestImpl:
    def isReverseNumber(self,number):
        copy=number
        rev=0
        while(number!=0):
            r=number%10
            rev=rev*10+r
            number=int(number/10)
        return copy==rev
#Drive code
obj=TestImpl()
print(obj.isReverseNumber(5005))
"""
OUTPUT
True
"""

Code in Java
/*Code in Java*/
import java.util.Scanner;

class RemoveCharacter {

    static boolean isReverseNumber(int number) {
        int rev = 0, r, copy = number;
        while (number != 0) {
            r = number % 10;
            rev = rev * 10 + r;
            number /= 10;
        }
        if (copy == rev) {
            return true;
        } else {
            return false;
        }
    }

    public static void main(String[] args) {

        System.out.println(isReverseNumber(5005));
    }
}
/*
OUTPUT
true
 */

Request:-If you found this post helpful then let me know by your comment and share it with your friend. 

If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all. 

If you have not subscribed my website then please subscribe my website. Try to learn something new and teach something new to other. 

Thanks

Post a Comment

0 Comments