nguyenhung1903

isPalindromes O(n/2)

Sep 11th, 2021 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. bool isPalindromes(int a, int i){
  2.     int nArray[(int)1e5+1], j = 0;
  3.     while (a>0) {nArray[j++] = a%i; a/=i;}
  4.     for (int k = 0; k<=j/2;++k)
  5.         if (nArray[k] != nArray[j-k - 1]) return false;
  6.     return true;
  7. }
Add Comment
Please, Sign In to add comment