leecode
binqiang2wang
这个作者很懒,什么都没留下…
展开
-
RecursionError: maximum recursion depth exceeded in comparison
如果保证代码正确,可以直接看Python递归深度错误:RecursionError: maximum recursion depth exceeded in comparison 策略简单陈述,就是扩大python内置的一个递归深度: import sys sys.setrecursionlimit(9000000) #这里设置大一些 我这里遇到的是因为代码本身有问题,这提示我,在递归的时候,一定要仔细检查递归体,别是自己写的和我一样是无限递归(奇异博士的赶脚) def dfs(x,y原创 2020-08-12 20:20:09 · 1194 阅读 · 0 评论 -
leecode day5 String to Integer (atoi)
Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from thi...原创 2018-08-05 23:44:50 · 157 阅读 · 0 评论 -
leecode day8 ZigZag Conversion
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 for better legibility) P A H N A P L S I I ...原创 2018-08-10 11:02:11 · 209 阅读 · 0 评论 -
leecode day1 twosum
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-08-01 17:47:36 · 236 阅读 · 0 评论 -
leecode day6 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. Exampl..原创 2018-08-06 21:16:02 · 215 阅读 · 0 评论 -
leecode day2 Merge Two Sorted Lists
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...原创 2018-08-02 22:07:05 · 173 阅读 · 0 评论 -
leecode day9 Regular Expression Matching
Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. T...原创 2018-08-13 15:05:36 · 210 阅读 · 0 评论 -
leecode day10 Count and Say
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-08-25 10:22:58 · 257 阅读 · 0 评论 -
leecode day11 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 not cont...原创 2018-09-18 11:17:13 · 186 阅读 · 0 评论 -
leecode day7 Container With Most Water
Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two l...原创 2018-08-09 23:08:15 · 191 阅读 · 0 评论 -
leecode day5 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"] Output: ...原创 2018-08-05 21:34:21 · 189 阅读 · 0 评论 -
leecode day5 Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and n...原创 2018-08-05 20:42:02 · 181 阅读 · 0 评论 -
leecode day3 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 modifyi...原创 2018-08-03 21:40:28 · 171 阅读 · 0 评论 -
leecode day3 Palindrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Expla...原创 2018-08-03 22:42:10 · 165 阅读 · 0 评论 -
leecode day3 Palindrome Linked List
Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) time a...原创 2018-08-03 23:51:04 · 244 阅读 · 0 评论 -
leecode day4 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 ...原创 2018-08-04 10:08:27 · 189 阅读 · 0 评论 -
leecode day4 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 ...原创 2018-08-04 11:37:48 · 174 阅读 · 0 评论 -
leecode day4 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 return i...原创 2018-08-04 14:19:28 · 202 阅读 · 0 评论 -
leecode day5 Valid Parentheses
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 b...原创 2018-08-05 13:33:39 · 192 阅读 · 0 评论 -
leecode day5 Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with...原创 2018-08-05 16:33:25 · 161 阅读 · 0 评论 -
leecode day3 Reverse Integer
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 ...原创 2018-08-03 17:46:40 · 155 阅读 · 0 评论
分享