1.c++
int ,long ,long long 转string,以及string 反转
bool palindromeNumber(int num) {
// Write your code here
int ss;
char temp[64];
string str;
ss=num;
sprintf(temp,"%d",ss);
string s(temp);
string a = s.c_str();
string b = a;
int len = a.length();
for(int i=0;i<len;i++){
if(a[i]!=b[len-1-i])
return false;
}
return true;
}
2.java
public boolean palindromeNumber(int num) {
// Write your code here
String a = num + "";
if(a.equals(StringBuilder(a).reverse().toString()))return true;
return false;
}
3.python
def palindromeNumber(self, num):
# Write your code here
a=str(num)
b=a[::-1]
if(a==b):
return True
else:
return False;
可见,在速度上三者的差异还是不可忽略的