2016年11月7日
摘要: 题目: 思路:如果链表为空或者n小于1,直接返回即可,否则,让链表从头走到尾,每移动一步,让n减1。 1.链表1->2->3,n=4,不存在倒数第四个节点,返回整个链表 扫过的节点依次:1-2-3 n值得变化:3-2-1 2.链表1->2->3,n=3 扫过的节点依次:1-2-3 n值得变化:2-1 阅读全文
posted @ 2016-11-07 22:01 一只笨笨鸟 阅读(169) 评论(0) 推荐(0) 编辑
  2016年11月4日
摘要: 题目: 思路:这题和15题很像,外层再加一个循环稍作修改即可 阅读全文
posted @ 2016-11-04 21:06 一只笨笨鸟 阅读(135) 评论(0) 推荐(0) 编辑
  2016年11月3日
摘要: 题目: 思路:设置两个List,一个存储当前层,一个存储最终层 阅读全文
posted @ 2016-11-03 21:51 一只笨笨鸟 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 题目: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integ 阅读全文
posted @ 2016-11-03 15:39 一只笨笨鸟 阅读(171) 评论(0) 推荐(0) 编辑
  2016年11月2日
摘要: 题目: 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 阅读全文
posted @ 2016-11-02 15:21 一只笨笨鸟 阅读(448) 评论(0) 推荐(0) 编辑
  2016年10月31日
摘要: 题目: Write a function to find the longest common prefix string amongst an array of strings. 思路:求最长前缀子串,假设第一个字符串是最长前缀子串,采用增强for得到数组中每个字符串,分别与第一个字符串的同一位置 阅读全文
posted @ 2016-10-31 20:35 一只笨笨鸟 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 思路:与12题正好相反,罗马数字基本字符集:I V X L C D M (1 阅读全文
posted @ 2016-10-31 17:05 一只笨笨鸟 阅读(217) 评论(0) 推荐(0) 编辑
  2016年10月30日
摘要: 题目: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 思路: 主要是了解罗马数和阿拉伯数字的对应关系,如下表: 由这个表基本上可以 阅读全文
posted @ 2016-10-30 20:24 一只笨笨鸟 阅读(258) 评论(0) 推荐(0) 编辑
  2016年10月29日
摘要: 题目: 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 e 阅读全文
posted @ 2016-10-29 21:57 一只笨笨鸟 阅读(172) 评论(0) 推荐(0) 编辑
  2016年10月28日
摘要: 题目: Implement regular expression matching with support for '.' and '*'. 思路:'.' 代表任意单字符,'*' 可以代表将前面的字符去掉,也可以代表是对前面字符(包括'.')的重复(数目无限)。例子: aa a //不匹配,很明显 阅读全文
posted @ 2016-10-28 20:28 一只笨笨鸟 阅读(230) 评论(0) 推荐(0) 编辑