摘要: Description: Determine whether an integer is a palindrome. Do this without extra space. 题意: 判断一个整数是不是回文数 思路: 注意负数不是回文数。 设整数为x, 定义一个rev来保存右边的回文, 当数字长度是 阅读全文
posted @ 2018-03-14 19:21 shengwudiyi 阅读(93) 评论(0) 推荐(0) 编辑
摘要: Description: Implement atoi to convert a string to an integer. 题意: 将字符串转换成integer 思路: 这个字符串的组成是, x个空格(x可为0) + 一个正负号(或者没有) + 加数字字符串, 中间若出现不是数字的字符,则计算之前 阅读全文
posted @ 2018-03-14 16:43 shengwudiyi 阅读(77) 评论(0) 推荐(0) 编辑
摘要: Description: Given a 32 bit signed integer, reverse digits of an integer. 题意: 倒置int32的整数 思路: 如果每次取余的话其实不用考虑正负,要注意的是边界, 倒置后的数有可能overflows,具体看代码 Example 阅读全文
posted @ 2018-03-14 09:31 shengwudiyi 阅读(67) 评论(0) 推荐(0) 编辑