题解 | #牛的回文编号#
牛的回文编号
https://www.nowcoder.com/practice/f864e31a772240f1b4310fbdc27fad48
知识点:回文串
思路:简单的回文串的判断,不多说思路
编程语言:java
import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param x int整型
* @return bool布尔型
*/
public boolean isPalindrome (int x) {
// write code here
StringBuilder sb = new StringBuilder(Integer.toString(x));
String ssb = sb.toString();
sb.reverse();
if(ssb.contentEquals(sb))
return true;
return false;
}
}
查看7道真题和解析