上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 30 下一页

2017年12月24日

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) 编辑

2017年12月23日

Longest Substring Without Repeating Characters

摘要: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng 阅读全文

posted @ 2017-12-23 21:31 夜的第八章 阅读(164) 评论(0) 推荐(0) 编辑

letter combinations of a phone number(回溯)

摘要: Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telepho 阅读全文

posted @ 2017-12-23 20:02 夜的第八章 阅读(191) 评论(0) 推荐(0) 编辑

remove Nth Node from linked list从链表中删除倒数第n个元素

摘要: Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After rem 阅读全文

posted @ 2017-12-23 16:46 夜的第八章 阅读(426) 评论(0) 推荐(0) 编辑

generate parentheses(生成括号)

摘要: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: 给 阅读全文

posted @ 2017-12-23 15:48 夜的第八章 阅读(165) 评论(0) 推荐(0) 编辑

排序算法入门之堆排序(Java实现)

摘要: 堆排序 在学习了二叉堆(优先队列)以后,我们来看看堆排序。堆排序总的运行时间为O(NlonN)。 堆的概念 堆是以数组作为存储结构。 可以看出,它们满足以下规律: 设当前元素在数组中以R[i]表示,那么(下标从0开始), (1) 它的左孩子结点是:R[2*i+1]; (2) 它的右孩子结点是:R[2 阅读全文

posted @ 2017-12-23 10:16 夜的第八章 阅读(607) 评论(0) 推荐(0) 编辑

2017年12月22日

Integer 和int 比较

摘要: 在jdk1.5的环境下,有如下4条语句: 1 2 3 4 Integer i01 = 59; int i02 = 59; Integer i03 =Integer.valueOf(59); Integer i04 = new Integer(59)。 Integer i01=59 的时候,会调用 I 阅读全文

posted @ 2017-12-22 22:01 夜的第八章 阅读(207) 评论(0) 推荐(0) 编辑

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 30 下一页

导航