Posts

Showing posts from August, 2024

LeetCode 9. Palindrome Number

  class Solution {      public boolean isPalindrome ( int x ) {          String str = String . valueOf (x);          int n = s . length ();          for ( int i = 0 ; i< n/ 2 ; i++) {              if ( str . charAt (i) != str . charAt (n - i - 1 ))                     return false ;         }          return true ;     } } Time Complexity: O(n) Space Complexity: O(n) class Solution {      public boolean isPalindrome ( int x ) {          if (x < 0 || (x != 0 && x % 10 == 0 )) return false ;        ...