`
vvaaiinn
  • 浏览: 20986 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论
文章列表
题目: 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 the second node from the end, the linked list becomes 1->2->3->5. Note: Givennwill always be valid. ...
题目: 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 target. Note: Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie,a≤b≤c≤d) The solution set must not cont ...
转自:http://blog.csdn.net/hutuchongaini/article/details/12945401 刚才刷LeetCode的碰到的一个小细节的问题,就是List的声明问题。 找了一个写的比较不错的文章,转之,学习之。 List是一个接口,而ListArray是一个类。 ListArray继承并实现了List。 所以List不能被构造,但可以向上面那样为List创建一个引用,而ListArray就可以被构造。 List list; //正确 list=null; List list=new List(); // 是错误的用法 List list ...
题目: Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string "23" Output: ["ad", "ae", "af", "bd& ...
题目: 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 may assume that each input would have exactly one solution. For example, given array S = {-1 2 1 -4}, and target = 1. The sum that is clo ...
最近实验室的安卓app需要实现发内部邮件的功能。 说白了就是简单的数据库的增删处理。 但是中间的一部分有意思的就是获取收件人的列表的处理。 用户在登录APP的时候,如果验证成功,服务器则把数据的联系人的所有信息发送回来到客户端。 发送出来的格式是dataset,处理之后转换为xml格式的字符串发出来。 当发邮件的时候 ,则会在收件人提供一个Spinner控件,然后把所有人的名字显示出来。 这个时候就涉及到xml格式的字符串的解析。 我的实现方法很简单。用的是PULL方法。希望能够帮助到需要的同学。 首先看服务器端发回的字符串格式 <span style="f ...
题目:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b
题目:Write a function to find the longest common prefix string amongst an array of strings. 翻译:求一个字符串数组中 共同的最长前缀。 思路:以第一个串为基准,逐个位置遍历,并遍历字符串数组,如果出现某个字符串长度小于当前位置,或者出现当前位置的字符不相同,返回字串strs[0].substring(0,pos);思路很简单。 代码: public String longestCommonPrefix(String[] strs) { int count = strs.length ...
题目: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 翻译:把罗马转为数字 思路:如果是单纯的一个罗马字母比较好处理,但是对于4,9这样的,应该看它下一个字符代表的数字是不是比他大,要是大的话减去当前的字符代表的数字。要是小的话,则加上这个数字。 像IV ,代表4.当读到I的时候,应该判断下一个字符V和I的关系,V比I代表的数字大,所以此时应该加上V - I的值,然后指针跳过2. 代码1: ...
题目: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 翻译: 给一个整数,把他转换为罗马数字输出。 这道题是简单的字符转换的问题。只要了解罗马数字代表的含义即可。 罗马数字里面只有 1,5,10. 1到3之间用重复的1表示,4用IV 90用XC 依次类推。 I = 1;
题目: Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most wate ...
从头到尾彻底理解KMP 转自:http://blog.csdn.net/v_july_v/article/details/7041827 感觉写的不错,看起来可以看懂 作者:July时间:最初写于2011年12月,2014年7月21日晚10点 全部删除重写成此文,随后的半个多月不断反复改进。 1. 引言 本KMP原文最初写于2年多前的2011年12月,因当时初次接触KMP,思路混乱导致写也写得混乱。所以一直想找机会重新写下KMP,但苦于一直以来对KMP的理解始终不够,故才迟迟没有修改本文。
题目: Implement regular expression matching with support for'.'and'*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). The function prototype should be: bool isMatch(const char *s, const char * ...
题目:Determine whether an integer is a palindrome. Do this without extra space. 翻译:判断一个数字是否是回文数,不要额外空间。 解题思路:因为数字既然传过去了,就不会有越界的问题。每次只需要取最前面和最后面的那一位数字进行比较,相同则继续,不同则返回、 首先要获取数字的位数,假设数字是12344321,一共有8位。 其次是要每次取前后各一位来进行比较,用数字除以1后面7个0得到第一位,用数字对10取余数得到最后一位。 此时要比较第二位和倒数第二位,只需将数字对1后面7个0取余后,在除以10.这样数字就变为234 ...
题目: 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 and ask yourself what are the possible input cases. Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). Y ...
Global site tag (gtag.js) - Google Analytics