python
文章平均质量分 60
拾-亦
--------------新手刷题,仅用于自身记录,如有错误,欢迎指出---------------
展开
-
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 132 阅读 · 0 评论 -
Same Tree/easy/day15(递归)
题目:Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example 1...原创 2018-05-02 19:55:52 · 109 阅读 · 0 评论 -
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 · 106 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 · 102 阅读 · 0 评论 -
Count and Say/easy/day11
题目:The count-and-say sequence is the sequence of integers with the first five terms as following:1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "one 1" or 11.11 is read off as...原创 2018-04-19 15:23:17 · 87 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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: 2 Example 2:Inpu...原创 2018-04-18 17:51:01 · 128 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
leetcode/Reverse Integer/easy/day2
题目Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123 Output: 321 Example 2:Input: -123 Output: -321 Example 3:Input: 120 Output: 21 Note:Assume we are dealing with an en...原创 2018-04-15 10:16:32 · 103 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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->4 Output: 1-&g...原创 2018-04-15 10:23:29 · 123 阅读 · 0 评论 -
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 阅读 · 0 评论