1,数组:
Three Sum(求三数之和)
英文版:https://leetcode.com/problems/3sum/
中文版:https://leetcode-cn.com/problems/3sum/
Majority Element(求众数)
英文版:https://leetcode.com/problems/majority-element/
中文版:https://leetcode-cn.com/problems/majority-element/
见证python暴力的时候到了,一行代码搞定:
return sorted(nums)[int(len(nums)/2)]
Missing Positive(求缺失的第一个正数)
英文版:https://leetcode.com/problems/first-missing-positive/
中文版:https://leetcode-cn.com/problems/first-missing-positive/
2,字符串: Reverse String (反转字符串)
英文版:https://leetcode.com/problems/reverse-string/
中文版:https://leetcode-cn.com/problems/reverse-string/
用python自带的函数反而是用时最少的,第一种放大是自建循环,用时居中,172s。
Reverse Words in a String(翻转字符串里的单词)
String to Integer (atoi)(字符串转换整数 (atoi))
英文版:https://leetcode.com/problems/string-to-integer-atoi/
中文版:https://leetcode-cn.com/problems/string-to-integer-atoi/
Reference:Leetcode-15: https://www.jianshu.com/p/dd8dcdd2baf8
Leetcode-41: https://blog.youkuaiyun.com/weixin_40449300/article/details/82532996
Leetcode-151: https://blog.youkuaiyun.com/sxingming/article/details/51597524