![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python 刷题日记
二当家的掌柜
这个作者很懒,什么都没留下…
展开
-
Python 刷题日记:LeetCode 204: Count Primes
原题: Description:Count the number of prime numbers less than a non-negative number, n.解题思路:常规解法:因为要求解小于n的素数个数,首先要解决如何判断一个素数。那么就是对于一个数x,只需对[2,]的数进行整除,若能整除则不是素数,不能整除则为素数。然后判断小于n的各个数是否为素数,这样做法的复杂度显然为O(n^2原创 2017-06-28 21:13:19 · 6001 阅读 · 0 评论 -
Python 刷题日记: Letter Combination of a Phone Number
原题: Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. (中文翻译:给定一个数字字符串,原创 2017-06-22 15:47:30 · 613 阅读 · 0 评论 -
Python刷题日记:LeetCode-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”,原创 2017-06-23 13:53:17 · 393 阅读 · 0 评论 -
Python 刷题日记:LeetCode 624. Maximum Distance in Arrays
原题: Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance be原创 2017-06-23 20:18:30 · 1347 阅读 · 0 评论 -
Python 刷题日记:LeetCode 5&9&516- Longest Palindromic Substring 题集合
原题:LeetCode 5 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:Input: "babad"Output: "bab"No原创 2017-06-25 20:40:45 · 1760 阅读 · 0 评论 -
Python 刷题日记:LeetCode: 1&15&16-Two Sum and 3Sum
这篇博文整理了关于做2Sum和3Sum的做题心得,这类题目都是给定一个整数数组和一个目标值,然后从数组中找出加和等于目标值的下标或值。LeetCode 1:Two Sum: Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may原创 2017-06-26 22:12:27 · 930 阅读 · 0 评论 -
和为S的连续正数序列
题目描述:小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100。但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数)。没多久,他就得到另一组连续正数和为100的序列:18,19,20,21,22。现在把问题交给你,你能不能也很快的找出所有和为S的连续正数序列? Good Luck!输出描述:输出所有和为S的连续正数原创 2018-01-28 23:54:24 · 338 阅读 · 0 评论