LeetCode-python版
大星小辰
这个作者很懒,什么都没留下…
展开
-
LeetCode5—— Longest Palindromic Substring
题目链接 Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer....原创 2019-02-21 19:13:51 · 106 阅读 · 0 评论 -
LeetCode94——Binary Tree Inorder Traversal
题目链接 Given a binary tree, return theinordertraversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,3,2] Follow up:Recursive solution is trivial, c...原创 2019-03-13 10:11:07 · 318 阅读 · 0 评论 -
LeetCode74——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 left to right. The first integer of ea...原创 2019-03-21 11:14:07 · 90 阅读 · 0 评论 -
LeetCode106——Construct Binary Tree from Inorder and Postorder Traversal
题目链接 Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given inorder =[9,3,15,20,7] postorde...原创 2019-03-21 09:39:41 · 92 阅读 · 0 评论 -
LeetCode105——Construct Binary Tree from Preorder and Inorder Traversal
题目链接 Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given preorder =[3,9,20,15,7] inorder ...原创 2019-03-21 09:25:41 · 99 阅读 · 0 评论 -
LeetCode26——Remove Duplicates from Sorted Array
题目链接 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 m...原创 2019-02-20 14:53:14 · 80 阅读 · 0 评论 -
LeetCode18——4Sum
题目链接 Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum ...原创 2019-02-19 20:18:22 · 114 阅读 · 0 评论 -
LeetCode16——3Sum Closest
题目链接 Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input ...原创 2019-02-19 16:55:50 · 62 阅读 · 0 评论 -
LeetCode15——3Sum
题目链接 Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must no...原创 2019-02-19 16:33:17 · 92 阅读 · 0 评论 -
LeetCode102——Binary Tree Level Order Traversal
题目链接 Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree[3,9,20,null,null,15,7], 3 / \ 9 ...原创 2019-02-28 11:10:23 · 109 阅读 · 0 评论 -
LeetCode101——Symmetric Tree
题目链接 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree[1,2,2,3,4,4,3]is symmetric: 1 / \ 2 2 / \ / \ 3 4 4...原创 2019-02-28 10:37:02 · 95 阅读 · 0 评论 -
LeetCode100——Same Tree
题目链接 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. Ex...原创 2019-02-28 10:18:11 · 90 阅读 · 0 评论 -
LeetCode3——Longest Substring Without Repeating Characters
题目链接 Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Examp...原创 2019-02-18 17:22:09 · 76 阅读 · 0 评论 -
LeetCode2——Add Two Numbers
题目链接 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and re...原创 2019-02-18 16:38:05 · 60 阅读 · 0 评论 -
LeetCode1——Two Sum
题目链接 暴力法 class Solution: def twoSum(self, nums: 'List[int]', target: 'int') -> 'List[int]': for i in range(0, len(nums)-1): for j in range(i+1, len(nums)): i...原创 2019-02-18 11:34:40 · 123 阅读 · 0 评论 -
LeetCode14——Longest Common Prefix
题目链接 Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: ["flower","flow","flight"] O...原创 2019-02-22 11:20:27 · 114 阅读 · 0 评论 -
LeetCode12——Roman to Integer
题目链接 Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D ...原创 2019-02-22 10:30:00 · 131 阅读 · 0 评论 -
LeetCode12——Integer to Roman
题目链接 Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D ...原创 2019-02-21 20:07:11 · 85 阅读 · 0 评论 -
LeetCode103——Binary Tree Zigzag Level Order Traversal
题目链接 Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given bina...原创 2019-03-13 10:48:22 · 129 阅读 · 0 评论