Solution 1: accepted 10%
Time: O(n)
Still get very bad performance (10%), try to replace syntax.
Alternative: without copy (slower)
Solution 2: accepted 17ms 25%
I think the performance varies on server condition…
|
|
Time: O(n)
Still get very bad performance (10%), try to replace syntax.
Alternative: without copy (slower)
I think the performance varies on server condition…
|
|
##Solution 2: accepted
|
|
Try to divide it into two parts.
|
|
Normal DP.
Time: O(nk) (k is the largest input[i])
Space: O(n)
|
|
DP.
Time: O(n)
Space: O(1)
|
|
7ms
8ms
Time: O(2n)
Space: O(n)
|
|
|
|
Add the new node to the list, and do the rest just like 056.
|
|
|
|
Time: O(n)
Space: O(1)
|
|
|
|
|
|
|
|
The given number has to be an integer. So “if (reversed > 214748364 || reversed < -214748364)” would be fine.
Even if it is a fit, the is not a palindrome.
|
|
Simplified. But do we need to check the entire number?
|
|
We only need to check half of the number
|
|
30 to 37~45.62 (15-16ms)
from char[] input = s.toCharArray()
to s.charAt(i)
25 to 30
from char current
to int current
18 to 25:
from after = input[i +1]
to after = current
Doesn’t make difference:
length
charAt / char[]
|
|