摘要: [题目] Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more lette 阅读全文
posted @ 2016-09-03 15:40 三刀 阅读(413) 评论(0) 推荐(0) 编辑
摘要: [题目] Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Fo 阅读全文
posted @ 2016-09-02 16:16 三刀 阅读(120) 评论(0) 推荐(0) 编辑
摘要: [题目] Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: Note: You may assum 阅读全文
posted @ 2016-09-01 22:39 三刀 阅读(149) 评论(0) 推荐(0) 编辑
摘要: [题目] Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, 阅读全文
posted @ 2016-08-29 11:22 三刀 阅读(87) 评论(0) 推荐(0) 编辑
摘要: [题目] Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. [题目 阅读全文
posted @ 2016-08-26 16:32 三刀 阅读(152) 评论(0) 推荐(0) 编辑
摘要: [题目] Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in 阅读全文
posted @ 2016-08-26 15:22 三刀 阅读(139) 评论(0) 推荐(0) 编辑
摘要: [题目] Determine whether an integer is a palindrome. Do this without extra space. [题目解析] 判断一个给定整数是否为回文数,回文数即121,11411这种正着和反着相同的数字,最小的回文数是0。实现思路可以比较直接,先对 阅读全文
posted @ 2016-08-26 12:09 三刀 阅读(110) 评论(0) 推荐(0) 编辑
摘要: [题目] Implement atoi to convert a string to an integer. [题目解析] 该题目比较常见,从LeetCode上看代码通过率却只有13.7%,于是编码提交,反复修改了三四次才完全通过。该题目主要需要考虑各种测试用例的情况,比如"+5"、" 67"、" 阅读全文
posted @ 2016-08-25 21:46 三刀 阅读(154) 评论(0) 推荐(0) 编辑
摘要: [题目] Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 [题目解析] 思路比较直接,这里要特别注意的是负数和整数越界的情况。 注意判断是否溢出的时候,是判断的Int 阅读全文
posted @ 2016-08-25 15:17 三刀 阅读(190) 评论(0) 推荐(0) 编辑
摘要: [题目] Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. [题目解析] 这道题很关键的是要理解罗马数字的几个主要的代表符号和表示方式 阅读全文
posted @ 2016-08-18 22:27 三刀 阅读(91) 评论(0) 推荐(0) 编辑