Problem solving with programming: Check if a number is the mirror image of itself
Only need traverse once ==>
https://www.hackerearth.com/problem/algorithm/mirror-of-mahatma-gandhi/description/
Given an arbitrarily large number, how to check if it is same as it's mirror image.
Given an arbitrarily large number, how to check if it is same as it's mirror image.
Only need traverse once ==>
Read full article from Problem solving with programming: Check if a number is the mirror image of itselfstring result = "YES";cin >> input;int i,j;for( i = 0; i < input.size(); i++ ){if( input[i] != '0' && input[i] != '1' && input[i] != '8' ){result = "NO";break;}}for( i = 0, j = input.size()-1; i <= j; i++, j--){if( input[i] != input[j] ){result = "NO";break;}}cout << result << endl;}