- 博客(17)
- 收藏
- 关注
原创 Merge Sorted Array/easy/day14
题目:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume that n...
2018-04-27 21:30:07 94
原创 Sqrt(x) + Valid Perfect Square/easy/day15
题目一:Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and only...
2018-04-26 20:57:21 111
原创 leetcode/ Add Binary/easy/day14
题目Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:Input: a = "11", b = "1"Output: "100"Example 2:I...
2018-04-25 20:47:56 133
原创 leetcode/Plus One/easy/day13
题目:Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each elemen...
2018-04-23 21:51:24 107
原创 leetcode/Length of Last Word/easy/day12
题目:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is define...
2018-04-23 21:47:42 135
原创 KMP算法(挖坑)
原理:假设第一次比较到 i 位不相等,那么字符串 f 移动 k 位应满足,前 i -1 位字符串的前缀A和后缀B相等;所以往后移的位数为 已匹配的长度 - 最长公共长度(当前长度的最长相等前后缀);最大前后缀公共长度被存在next数组中最长前缀:是说以第一个字符开始,但是不包含最后一个字符算法计算next数组:字符串下标为i,为第i+1个字符,对应next[i+1],如果字符串第i位与next[...
2018-04-20 13:12:25 103
原创 Count and Say/easy/day11
题目:The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1" or 11.11 is read off as...
2018-04-19 15:23:17 87
原创 Search Insert Position/easy/day10
题目: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 order.You may assume no duplicates in the array.E...
2018-04-19 14:14:08 95
原创 leetcode/Implement strStr()/easy/day9
题目Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Example 2:Inpu...
2018-04-18 17:51:01 128
原创 leetcode/Remove Element/easy/day8
题目:Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input arr...
2018-04-18 11:25:44 103
原创 leetcode/Remove Duplicates from Sorted Array/easy/day7
题目:Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modify...
2018-04-16 21:17:20 127
原创 leetcode/ Merge Two Sorted Lists/easy/day6
题目: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.Example:Input: 1->2->4, 1->3->4Output: 1-&g...
2018-04-15 10:23:29 124
原创 leetcode/two sum/day1
题目Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same ...
2018-04-15 10:17:25 103
原创 leetcode/Reverse Integer/easy/day2
题目Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are dealing with an en...
2018-04-15 10:16:32 105
原创 leetcode/Palindrome Number/easy/day3
题目Determine whether an integer is a palindrome. Do this without extra space.个人解法利用上一题反转数字,若反转后和原数字相等,则为回文数字class Solution: def isPalindrome(self, x): """ :type x: int :rtype: b...
2018-04-15 10:15:48 90
原创 leetcode/Longest Common Prefix/easy/day4
题目:Write a function to find the longest common prefix string amongst an array of strings.我的暴力解法: def longestCommonPrefix(self, strs): if not strs: return "" length = len(st...
2018-04-15 10:14:59 103
原创 Valid Parentheses/easy/day5
题目:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of br...
2018-04-15 10:12:05 104
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人