2017年12月24日

3sum(从数组中找出三个数的和为0)

摘要: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of 阅读全文

posted @ 2017-12-24 21:34 夜的第八章 阅读(1621) 评论(0) 推荐(0) 编辑

integer to roman

摘要: Input is guaranteed to be within the range from 1 to 3999. 将整数转成罗马数字。。下面答案比较厉害了。它将每个位置上(每位数)可能出现的情况先列出来,然后匹配 阅读全文

posted @ 2017-12-24 17:15 夜的第八章 阅读(125) 评论(0) 推荐(0) 编辑

String to Integer (atoi)

摘要: 将字符串转成整数,跳过前面的空格。。然后转的时候注意防止溢出。。total=total*10+digit 这个检查溢出的方式要掌握:最大整数除以10比total小(说明total*10就要溢出),当最大整数除以10等于total,且余数小于digit,那么执行上面公式也会溢出。。 if(Intege 阅读全文

posted @ 2017-12-24 17:05 夜的第八章 阅读(175) 评论(0) 推荐(0) 编辑

zigzag conversion

摘要: 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-12-24 16:19 夜的第八章 阅读(171) 评论(0) 推荐(0) 编辑

Longest Palindromic Substring(最长回文子串)

摘要: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Example: 从字符串中找出最长的回文子串,该 阅读全文

posted @ 2017-12-24 15:31 夜的第八章 阅读(126) 评论(0) 推荐(0) 编辑

导航