10 2015 档案

[LeetCode]48. Word Pattern匹配模式
摘要:Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter... 阅读全文

posted @ 2015-10-31 09:56 AprilCheny 阅读(205) 评论(0) 推荐(0)

Ubuntu 14.04中安装Sublime Text 3并使用SublimeClang插件
摘要:转载请说明出处:http://blog.csdn.net/cywosp/article/details/32721011 Sublime Text是个跨平台的编辑器,支持Windows、Linux、Mac系统平台,支持各种语言的代码编辑,配合上对应的插件,话上点时间学习,你将会对它 爱不释手,大大的... 阅读全文

posted @ 2015-10-30 10:02 AprilCheny 阅读(445) 评论(0) 推荐(0)

[LeetCode]47. Integer to English Words整数的读法
摘要:Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231- 1.For example,123 -> "One Hundred T... 阅读全文

posted @ 2015-10-29 11:11 AprilCheny 阅读(232) 评论(0) 推荐(0)

[LeetCode]46. Restore IP Addresses复原IP地址
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example: Given "25525511135", return ["2... 阅读全文

posted @ 2015-10-28 20:57 AprilCheny 阅读(155) 评论(0) 推荐(0)

[LeetCode]45. Reverse Words in a String按单词翻转字符串
摘要:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C prog... 阅读全文

posted @ 2015-10-28 10:30 AprilCheny 阅读(234) 评论(0) 推荐(0)

[LeetCode]44. Implement strStr()实现strStr()函数
摘要:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02): The s... 阅读全文

posted @ 2015-10-26 20:54 AprilCheny 阅读(182) 评论(0) 推荐(0)

[LeetCode]43. Integer to Roman整数转罗马数字
摘要:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.解法:与罗马数字转整数过程相反。例如数字2438,罗马数字表示为MM CD XXX VI... 阅读全文

posted @ 2015-10-26 10:43 AprilCheny 阅读(243) 评论(0) 推荐(0)

[LeetCode]42. Roman to Integer罗马数字转整数
摘要:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.罗马数字基本字符共7个,即I(1)、V(5)、X(10)、L(50)、C(100)、D(... 阅读全文

posted @ 2015-10-26 09:44 AprilCheny 阅读(341) 评论(0) 推荐(0)

[LeetCode]41. String to Integer(atoi)字符串转整数
摘要:Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文

posted @ 2015-10-25 17:57 AprilCheny 阅读(240) 评论(0) 推荐(0)

[LeetCode]40. Valid Palinadrome有效回文串
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana... 阅读全文

posted @ 2015-10-25 09:57 AprilCheny 阅读(164) 评论(0) 推荐(0)

[LeetCode]39. Longest Valid Parentheses最长有效括号对
摘要:待补充。Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the lon... 阅读全文

posted @ 2015-10-24 18:20 AprilCheny 阅读(154) 评论(0) 推荐(0)

[LeetCode]38. Length of Last Word最后单词长度
摘要:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe... 阅读全文

posted @ 2015-10-24 18:16 AprilCheny 阅读(189) 评论(0) 推荐(0)

[LeetCode]37. Count and Say计数和读法
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw... 阅读全文

posted @ 2015-10-24 11:23 AprilCheny 阅读(404) 评论(0) 推荐(0)

[LeetCode]36. Compare Version Numbers版本号比较
摘要:Compare two version numbersversion1andversion2.Ifversion1>version2return 1, ifversion1 vs1 = split(version1, '.'); vector vs2 = split(version2,... 阅读全文

posted @ 2015-10-24 09:32 AprilCheny 阅读(215) 评论(0) 推荐(0)

[LeetCode]35. Valid Parentheses有效括号
摘要:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文

posted @ 2015-10-23 11:06 AprilCheny 阅读(133) 评论(0) 推荐(0)

[LeetCode]34. Add Binary二进制相加
摘要:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".解法:从后往前对两个string相加即可。注意将char转换为int,注意进位,注意结果顺序。... 阅读全文

posted @ 2015-10-23 10:09 AprilCheny 阅读(175) 评论(0) 推荐(0)

[LeetCode]33. Longest Palindromic Substring最长回文子串
摘要:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa... 阅读全文

posted @ 2015-10-22 11:31 AprilCheny 阅读(173) 评论(0) 推荐(0)

[LeetCode]32. Longest Common Prefix最长公共前缀
摘要:Write a function to find the longest common prefix string amongst an array of strings.解法:从所有的string的头到尾的字母逐一比较即可。class Solution {public: string lon... 阅读全文

posted @ 2015-10-22 11:27 AprilCheny 阅读(142) 评论(0) 推荐(0)

[LeetCode]31. Best Time to Buy and Sell Stock股票买卖
摘要:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie... 阅读全文

posted @ 2015-10-17 20:48 AprilCheny 阅读(199) 评论(0) 推荐(0)

[LeetCode]30. KSum问题总结
摘要:[LeetCode]1. 2Sum题目:https://leetcode.com/problems/two-sum/,解答:http://www.cnblogs.com/aprilcheny/p/4823576.html;[LeetCode]2. 3Sum题目:https://leetcode.co... 阅读全文

posted @ 2015-10-17 20:20 AprilCheny 阅读(262) 评论(0) 推荐(0)

[LeetCode]29. 4Sum四数之和
摘要: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-10-17 19:57 AprilCheny 阅读(285) 评论(0) 推荐(0)

[LeetCode]28. Search a 2D Matrix矩阵查找
摘要:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... 阅读全文

posted @ 2015-10-16 11:19 AprilCheny 阅读(236) 评论(0) 推荐(0)

[LeetCode]27. Rotate Image图像旋转
摘要:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?解法1:新开辟一个矩阵,空间复杂度O(... 阅读全文

posted @ 2015-10-15 17:25 AprilCheny 阅读(146) 评论(0) 推荐(0)

[LeetCode]26. Search in Rotated Array II旋转数组查找II
摘要:Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文

posted @ 2015-10-15 15:51 AprilCheny 阅读(186) 评论(0) 推荐(0)

[LeetCode]25. Search in Rotated Array旋转数组查找I
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文

posted @ 2015-10-14 11:54 AprilCheny 阅读(1836) 评论(0) 推荐(0)

[LeetCode]24. Search Insert Position插入位置
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文

posted @ 2015-10-13 20:16 AprilCheny 阅读(157) 评论(0) 推荐(0)

[LeetCode]23. Set Matrix Zeroes矩阵清零
摘要:Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A s... 阅读全文

posted @ 2015-10-13 19:22 AprilCheny 阅读(510) 评论(0) 推荐(0)

[LeetCode]22. 3Sum Closest最近三者之和
摘要: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-10-13 10:24 AprilCheny 阅读(211) 评论(0) 推荐(0)

[LeetCode]21. 3Sum三者之和
摘要: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-10-12 20:12 AprilCheny 阅读(6304) 评论(0) 推荐(0)

[LeetCode]20. Unique Paths II唯一路径
摘要:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i... 阅读全文

posted @ 2015-10-09 21:32 AprilCheny 阅读(176) 评论(0) 推荐(0)

[LeetCode]19. Unique Paths唯一路径
摘要:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文

posted @ 2015-10-09 19:40 AprilCheny 阅读(202) 评论(0) 推荐(0)

[LeetCode]18. Contains Duplicate II重复检测
摘要:Given an array of integers and an integerk, find out whether there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the differe... 阅读全文

posted @ 2015-10-09 09:56 AprilCheny 阅读(230) 评论(0) 推荐(0)

[LeetCode]17. Majority Element主元素
摘要:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文

posted @ 2015-10-08 11:24 AprilCheny 阅读(245) 评论(0) 推荐(0)

[LeetCode]16. Pascal's Triangle II杨辉三角
摘要:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(... 阅读全文

posted @ 2015-10-07 19:59 AprilCheny 阅读(149) 评论(0) 推荐(0)

[LeetCode]15. Pascal's Triangle杨辉三角
摘要:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]... 阅读全文

posted @ 2015-10-07 19:40 AprilCheny 阅读(206) 评论(0) 推荐(0)

[LeetCode]14. Remove Duplicates from Sorted Array排序数组去重
摘要:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a... 阅读全文

posted @ 2015-10-07 17:57 AprilCheny 阅读(232) 评论(0) 推荐(0)

[LeetCode]13. Remove Element移除元素
摘要:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文

posted @ 2015-10-06 11:17 AprilCheny 阅读(303) 评论(0) 推荐(0)

[LeetCode]12. Rotate Array旋转数组
摘要:Rotate an array ofnelements to the right byksteps.For example, withn= 7 andk= 3, the array[1,2,3,4,5,6,7]is rotated to[5,6,7,1,2,3,4].Note:Try to come... 阅读全文

posted @ 2015-10-06 10:11 AprilCheny 阅读(163) 评论(0) 推荐(0)

[LeetCode]11. Plus One加一运算
摘要:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at... 阅读全文

posted @ 2015-10-05 09:09 AprilCheny 阅读(263) 评论(0) 推荐(0)

[LeetCode]10. Contains Duplicate重复检测
摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr... 阅读全文

posted @ 2015-10-04 22:53 AprilCheny 阅读(224) 评论(0) 推荐(0)

[LeetCode]9. Summary Ranges统计范围
摘要:Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"].解法:(1)初始化... 阅读全文

posted @ 2015-10-04 10:17 AprilCheny 阅读(186) 评论(0) 推荐(0)

[LeetCode]8. Number of 1 Bits二进制表示中1的个数
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in... 阅读全文

posted @ 2015-10-03 09:59 AprilCheny 阅读(905) 评论(0) 推荐(0)

[LeetCode]7. ZigZag Conversion ZigZag转换
摘要: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 fo... 阅读全文

posted @ 2015-10-02 22:49 AprilCheny 阅读(307) 评论(0) 推荐(0)

[LeetCode]6. Merge Sorted Arrays合并排序数组
摘要:Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size that is great... 阅读全文

posted @ 2015-10-02 19:59 AprilCheny 阅读(183) 评论(0) 推荐(0)

[LeetCode]5. Move Zeros移动0到数组末尾
摘要:Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For example, givenn... 阅读全文

posted @ 2015-10-02 19:48 AprilCheny 阅读(1019) 评论(0) 推荐(0)