【LeetCode】 Determine whether an integer is a palindrome. Do this without extra space
来源:互联网 发布:河北工业大学知乎 编辑:程序博客网 时间:2024/05/19 19:42
/** * */package com.cxm;/** * @author admin *【LeetCode】 Determine whether an integer is a palindrome. Do this without extra space */public class PalindromeNumber{//Determine whether an integer is a palindrome. Do this without extra spaceprivate static Integer i = 122;public static boolean solution(){String str = String.valueOf(i);char[] strChar = str.toCharArray();int intL = strChar.length;int length = strChar.length>>1;int i =0;while(i<length){if(strChar[i]!=strChar[intL-i-1]){return false;}i++;}return true;}public static void main(String[] args){System.out.println(solution());}public static boolean solution1(){int rev = 0;int a = i ;while(i!=0){rev=rev*10+i%10;i/=10;}return rev==a;}}
0 0
- 【LeetCode】 Determine whether an integer is a palindrome. Do this without extra space
- Determine whether an integer is a palindrome. Do this without extra space.
- Determine whether an integer is a palindrome. Do this without extra space.
- Determine whether an integer is a palindrome. Do this without extra space.
- 3、Determine whether an integer is a palindrome
- P31 (**) Determine whether a given integer number is prime.
- leetCode Given an integer (signed 32 bits), write a function to check whether it is a power of 4
- Check whether a string is a palindrome
- This is a prerequisite condition to test whether sufficient total swap space is available on system
- Given an integer, write a function to determine if it is a power of two.
- Given an integer, write a function to determine if it is a power of two
- careercup1.3: remove duplicate without extra space.
- P33 (*) Determine whether two positive integer numbers are coprime.
- test if a string is an integer?
- isa - Determine whether input is object of given class matlab
- Determine whether the text is in Chinese or English
- This is an A+B Problem
- CareerCup Facebook Judge Whether a K-palindrome
- 类似微信陌陌app百万级并发系统源码转让
- 电机上下限位换向电路设计
- Ubuntu下OpenGL开发环境的搭建(转载)
- 14.3.2 提取数据字典
- 2014.04.04 因思考而失眠
- 【LeetCode】 Determine whether an integer is a palindrome. Do this without extra space
- openfire安装及配置
- ubuntu创建、删除文件及文件夹,强制清空回收站方法
- 14.3.3 分析一个或多个重做日志文件
- 本文介绍如何实现对应用加锁的功能,无须root权限
- THIS_MODULE详解
- Jquery编码便准最佳实践
- Linux - vi 使用时所遇问题
- 14.3.1 LogMiner的工作方式