- 博客(16)
- 收藏
- 关注
原创 LeetCode: 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 would ...
2019-03-31 13:57:05
190
原创 LeetCode: 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 contai...
2019-03-03 13:59:53
178
原创 LeetCode: 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: "fl...
2019-03-02 22:07:08
210
原创 爬取的网页,获取子元素内容的方法
今天练习网络爬虫,爬取豆瓣电影Top 250,其中每部电影有排名、评分、电影名、导演等信息,分布在不同的标签下面,而每部电影的所有信息都在一个大的标签下,因此需要获取子元素的内容。查了一下只看到有人用循环嵌套的方法遍历子元素,感觉略麻烦,后来发现.contents属性可以方便地获取子元素内容,因此采用。首先爬取第一页的内容,将所有电影的信息存入targets,用for循环遍历(使用break的目...
2019-03-02 09:10:38
1786
原创 LeetCode: Roman to Integer
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...
2019-02-27 10:52:00
157
原创 LeetCode: Integer to Roman
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...
2019-02-27 09:55:34
141
原创 LeetCode: 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...
2019-02-26 20:49:02
242
原创 LeetCode: 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: 121Output: trueExample 2:Input: -121Output: falseExplanation...
2019-02-26 09:03:10
228
原创 LeetCode: 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 this...
2019-02-25 22:21:56
243
原创 LeetCode: Reverse Integer
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 ...
2019-02-25 16:05:03
236
原创 LeetCode: 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 NA P L S I I G...
2019-02-24 15:25:46
127
原创 LeetCode: Two Sum
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 e...
2019-02-21 19:06:40
133
原创 LeetCode: 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...
2019-02-21 19:00:24
161
原创 LeetCode: Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcabcbb”Output: 3Explanation: The answer is “abc”, with the length of 3.Example 2:Input: ...
2019-02-21 18:55:24
124
原创 LeetCode: 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 num...
2019-02-21 18:49:10
117
原创 LeetCode: 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.Example ...
2019-02-21 18:38:31
173
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人