摘要: 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) 编辑
摘要: Description: The string __"PAYPALISHIRING"__ is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern 阅读全文
posted @ 2018-03-13 21:26 shengwudiyi 阅读(108) 评论(0) 推荐(0) 编辑
摘要: Description: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. 题意: 找出最长的回文串 思路: 题目的标 阅读全文
posted @ 2018-03-13 20:41 shengwudiyi 阅读(450) 评论(0) 推荐(0) 编辑
摘要: Description: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time 阅读全文
posted @ 2018-03-13 20:22 shengwudiyi 阅读(87) 评论(0) 推荐(0) 编辑
摘要: Description: Given a string, find the length of the longest substring without repeating characters. 题意: 输入一个字符串, 输出最长不重复子串的长度 思路: 比较一般的思路是, 只要是有关于重复的应 阅读全文
posted @ 2018-03-12 21:56 shengwudiyi 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Description: You are given two non empty linked lists representing two non negative integers. The digits are stored in reverse order and each of their 阅读全文
posted @ 2018-03-12 20:15 shengwudiyi 阅读(102) 评论(0) 推荐(0) 编辑
摘要: Description: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input 阅读全文
posted @ 2018-03-12 10:59 shengwudiyi 阅读(90) 评论(0) 推荐(0) 编辑