title: Palindrome Number time limit exceeded error dart
body: <p>First i want to say that i am trying to solve Palindrome Number problem on LeetCode using dart, of course
  <a href="https://leetcode.com/problems/palindrome-number/" rel="nofollow noreferrer">https://leetcode.com/problems/palindrome-number/</a></p>
  <p>So far I have tried total 6 different method to solve the problem.
  And am  not very happy to say that all of them leading to time limit exceeded error on LeetCode.. Solutions are perfectly working on terminal because of the less test cases but when submit, and it tried on large number it ends up error.</p>
  <p>My 6 solutions based on different classes.each class contain their own implemented solution..
  I dont know if the while loop in dart is slow or something wrong with the leetcode</p>
  <pre class="lang-dart prettyprint-override"><code>
  class A {
  
    bool isPalindrome(int x) {
  
      if (x &lt; 0) {
        return false;
      }
  
      double divisor = 1;
      while (x / divisor &gt;= 10) {
        divisor *= 10;
      }
      while (x != 0) {
        if ((x / divisor).truncate() != (x % 10).floor()) {
          return false;
        }
        x %= divisor.toInt();
        x = (x / 10).floor();
        divisor /= 100;
      }
  
      return true;
    }
  }
  
  class B {
  
    bool isPalindrome(int x) {
      if (x &lt; 0 || (x % 10 == 0 &amp;&amp; x != 0)) {
        return false;
      }
  
      int revNum = 0;
      while (x &gt; revNum) {
        revNum = revNum * 10 + x % 10;
        x = (x / 10).floor();
      }
  
      return (x == revNum || x == revNum / 10);
    }
  }
  
  class C {
  
    bool isPalindrome(int x) {
      if (x &lt; 0) {
        return false;
      }
      int y = 0;
      int xx = x;
  
      if (xx &gt; 0) {
        y = y * 10 + xx % 10;
        xx = (xx / 10).floor();
      }
      return (y != x);
    }
  
    // while (xx &gt; 0) {
    //   y = y * 10 + xx % 10;
    //   xx = (xx / 10).floor();
    // }
  }
  
  class D {
    bool isPalindrome(int x) {
      if (x.isNegative) return false;
      final list = convert(x);
      for (var i = 0; i &lt; (list.length ~/ 2); i++) {
        if (list[i] != list[list.length - 1 - i]) return false;
      }
      return true;
    }
  
    List convert(int x) {
      final List&lt;int&gt; list = &lt;int&gt;[];
  
      while (x &gt; 0) {
        list.add(x % 10);
        x = x ~/ 10;
      }
      return list;
    }
  }
  
  class F {
    bool isPalindrome(int x) {
      if (x.isNegative) return false;
      if (x == 0) return true;
      if (x % 10 == 0) return false;
  
      var reverted = 0, iter = x;
      while (iter &gt; 0) {
        reverted = reverted * 10;
        reverted += iter % 10;
        iter = iter ~/ 10;
      }
  
      return reverted == x;
    }
  }
  
  class G {
    bool isPalindrome(int x) {
      if (x.isNegative) return false;
  
      var tens = 10;
      while (tens &lt; x) tens *= 10;
      tens = tens ~/ 10;
  
      while (x &gt; 10) {
        var lastDigit = x % 10;
        var firstDigit = x ~/ tens;
  
        if (lastDigit != firstDigit) return false;
  
        x -= firstDigit * tens;
        x = x ~/ 10;
        tens = tens ~/ 100;
      }
  
      return true;
    }
  }
  
  </code></pre>