摘要: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 解法: 只要考虑两种情况即可: 第一,如果当前数字是最后一个数字,或者之后的数字比它 阅读全文
posted @ 2017-02-16 00:26 Strugglion 阅读(141) 评论(0) 推荐(0) 编辑
摘要: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 解释: 罗马数字采用七个罗马字母作数字、即Ⅰ(1)、X(10)、C(100)、M(1 阅读全文
posted @ 2017-02-15 22:51 Strugglion 阅读(192) 评论(0) 推荐(0) 编辑
摘要: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo 阅读全文
posted @ 2017-02-15 17:09 Strugglion 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Implement regular expression matching with support for '.' and '*'. 解法1: 这道题中的*表示*之前的那个字符可以有0个,1个或是多个,就是说,字符串a*b,可以表示b或是aaab,即a的个数任意;字符串.*b,可以表示b或是xyz 阅读全文
posted @ 2017-02-14 22:11 Strugglion 阅读(252) 评论(0) 推荐(0) 编辑
摘要: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thi 阅读全文
posted @ 2017-02-13 00:28 Strugglion 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below 阅读全文
posted @ 2017-02-12 23:57 Strugglion 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer. Example1: Example2: Have you thought about this? Here are some good questions to ask before coding. Bonus points for you 阅读全文
posted @ 2017-02-12 17:58 Strugglion 阅读(173) 评论(0) 推荐(0) 编辑
摘要: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font 阅读全文
posted @ 2017-02-12 15:56 Strugglion 阅读(178) 评论(0) 推荐(0) 编辑
摘要: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. 求字符串中的最大回文子串(从左往右和从右往左读一样的子串)。 Exa 阅读全文
posted @ 2017-02-12 00:51 Strugglion 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 关于这三个类在字符串处理中的位置不言而喻,那么他们到底有什么优缺点,到底什么时候该用谁呢?下面我们从以下几点说明一下。 1.三者在执行速度方面的比较:StringBuilder > StringBuffer > String 2.String <(StringBuffer,StringBuilder 阅读全文
posted @ 2017-02-11 15:32 Strugglion 阅读(5633) 评论(0) 推荐(0) 编辑