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
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.
0 Comments