2015年4月23日
摘要: Given a linked list, remove thenthnode from the end of list and return its head.For example.Given linked list: 1->2->3->4->5, and n = 2.After removing... 阅读全文
posted @ 2015-04-23 16:23 NealCaffrey989 阅读(154) 评论(0) 推荐(0) 编辑
  2015年4月22日
摘要: Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ... 阅读全文
posted @ 2015-04-22 22:07 NealCaffrey989 阅读(117) 评论(0) 推荐(0) 编辑
  2015年4月21日
摘要: Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon... 阅读全文
posted @ 2015-04-21 14:58 NealCaffrey989 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文
posted @ 2015-04-21 14:56 NealCaffrey989 阅读(177) 评论(0) 推荐(0) 编辑
  2015年4月20日
摘要: 题目:时间限制:2000ms单点时限:1000ms内存限制:256MB描述给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期)。只有闰年有2月29日,满足以下一个条件的年份为闰年:1. 年份能被4整除但不能被100整除2. 年份能被400整除输入第一行为一个整数T,表示数据组数。之后每... 阅读全文
posted @ 2015-04-20 22:33 NealCaffrey989 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 题目:时间限制:2000ms单点时限:1000ms内存限制:256MB描述给定字符串,求它的回文子序列个数。回文子序列反转字符顺序后仍然与原序列相同。例如字符串aba中,回文子序列为"a", "a", "aa", "b", "aba",共5个。内容相同位置不同的子序列算不同的子序列。输入第一行一个整... 阅读全文
posted @ 2015-04-20 22:26 NealCaffrey989 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 题目:时间限制:2000ms单点时限:1000ms内存限制:256MB描述需要在一个N × M的网格中建立一个通讯基站,通讯基站仅必须建立在格点上。网格中有A个用户,每个用户的通讯代价是用户到基站欧几里得距离的平方。网格中还有B个通讯公司,维护基站的代价是基站到最近的一个通讯公司的路程(路程定义为曼... 阅读全文
posted @ 2015-04-20 22:25 NealCaffrey989 阅读(220) 评论(0) 推荐(0) 编辑
  2015年4月19日
摘要: Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen... 阅读全文
posted @ 2015-04-19 22:31 NealCaffrey989 阅读(190) 评论(0) 推荐(0) 编辑
摘要: Write a function to find the longest common prefix string amongst an array of strings.本题寻找一组字符串的公共前缀,只需要查询较短子串前n个字符是否相等。时间:8ms代码如下:class Solution {pub... 阅读全文
posted @ 2015-04-19 22:30 NealCaffrey989 阅读(114) 评论(0) 推荐(0) 编辑
  2015年4月16日
摘要: Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.简单的字符转化,将读取的字符每一位转化为对应数字,再计算。时间:58ms代码如下:cla... 阅读全文
posted @ 2015-04-16 22:46 NealCaffrey989 阅读(124) 评论(0) 推荐(0) 编辑