自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 LeetCode算法题之213. House Robber II(medium)【Python3题解】

题目描述:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first hou...

2020-04-29 22:35:01 274

原创 LeetCode算法题之198. House Robber(easy)【Python3动态规划题解】

题目描述:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent...

2020-04-28 23:39:46 267 1

原创 LeetCode算法题之41. First Missing Positive(hard)【Python3题解】

题目描述:Given an unsorted integer array, find the smallest missing positive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Input: [7,8,9,11,12]Output: 1...

2020-04-26 21:19:27 165

原创 LeetCode算法题之66. Plus One(easy)【Python3题解】

题目描述:Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each el...

2020-04-25 22:41:21 173

原创 LeetCode算法题之35. Search Insert Position(easy)【Python3题解】

题目描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the arr...

2020-04-24 22:37:27 137

原创 LeetCode算法题之309. Best Time to Buy and Sell Stock with Cooldown(medium)【Python3题解】

题目描述:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy...

2020-04-23 12:50:20 201

原创 LeetCode算法题之122. Best Time to Buy and Sell Stock II(easy)【Python3题解】

题目描述:Say you have an array prices for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (...

2020-04-22 22:11:58 286

原创 LeetCode算法题之121. Best Time to Buy and Sell Stock(easy)【Python3动态规划题解】

题目描述:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the st...

2020-04-22 11:18:51 308

原创 LeetCode算法题之70. Climbing Stairs(easy)【Python3递归+动态规划题解】

题目描述:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a posi...

2020-04-20 21:17:02 206

原创 LeetCode算法题之53. Maximum Subarray(easy)【Python3动态规划题解】

先说大感谢:此篇文章的成型,要特别感谢一个人,labuladong,东哥,算法界一哥,扛把子,得益于他的指点在此也推荐他的公众号,以及他的GitHub仓库,现在已经很火了,公众号:labuladong,GitHub:手把手教你扒LeetCode的裤子,因为很火爆,也很实用,大家应该能找得到,希望看到并感兴趣的朋友,也去学一学好了,开始了题目描述:Given an integer ...

2020-04-20 11:33:34 215

原创 LeetCode算法题之16. 3Sum Closest(medium)【Python3题解】

题目描述: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 ...

2020-04-17 10:24:24 190

原创 梯度下降(Gradient Descent)法自动求解一元线性回归中的w,b参数

Step 1:定义损失函数(Loss Function):def loss(w, b, point): total_error = 0#初始化误差值 # 遍历每一个点,将每一个点的误差计算,并加和,且除以N(点的数量) for i in range(len(point)): x = point[i][0] y = point[i][1]...

2020-04-15 22:32:27 1235

原创 LeetCode算法题之28. Implement strStr()(easy)【Python3题解】

题目描述:Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = “hello”, needle = “ll”Output: 2Example...

2020-04-15 12:15:33 142

原创 LeetCode算法题之32. Longest Valid Parentheses(hard)【Python3题解】

题目描述:Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: “(()”Output: 2Explanation: The longest va...

2020-04-14 21:20:10 167

原创 LeetCode算法题之10. Regular Expression Matching(hard)【Python3递归法个人详解】

先聊一聊背景如题目所述,这道LeetCode经典算法题,中文名称是正则表达式匹配,如果你已经是刷题的高手,或者还是刚刚刷题的新手,比如我。那么你一定在LeetCode遇到过这道题。那么对于我这个刚刚上路的新手来说,因为这道题的排序是第十位,而我刷题是按照顺序来的,所以很快就遇到了它,结果就是跳过了。。。当时也在网上找过一些答案,基本两种解法最流行吗,其一,是递归;也就是本文将要解释的。其二,...

2020-04-13 12:17:07 245

原创 LeetCode算法题之47. Permutations II(medium)【Python3题解】

题目描述:Given a collection of numbers that might contain duplicates, return all possible unique permutations.Example:Input: [1,1,2]Output:[[1,1,2],[1,2,1],[2,1,1]]题目大意:给定一个数组,但是包含重复的数字,返回所有的不...

2020-04-12 11:02:22 170

原创 LeetCode算法题之46. Permutations(medium)【Python3题解】

题目描述:Given a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]题目大意:如题目所示,意为排列,置换,也就是将给定的数组...

2020-04-12 10:24:35 192

原创 LeetCode算法题之40. Combination Sum II(medium)

题目描述:Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.Each number in candidate...

2020-04-10 12:01:16 142

原创 LeetCode算法题之39. Combination Sum(medium)

题目描述:Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.The same r...

2020-04-09 19:50:19 182

原创 LeetCode算法题之22. Generate Parentheses(medium)

题目描述:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[“((()))”,“(()())”,“(())()”,“()(())”,“()...

2020-04-06 11:21:08 172

原创 Python中字符串的 join()函数简单用法

函数名:join()作用:将可迭代对象中的字符串类型数据,提取出来,串联在一起,具体见实例调用方法:str.join(iterable)参数:iterable:可迭代的对象,如列表,字符串等官方解释:str.join(iterable)Return a string which is the concatenation of the strings in iterable.A ...

2020-04-05 16:16:44 1022

原创 LeetCode算法题之17. Letter Combinations of a Phone Number(medium)

题目描述:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) i...

2020-04-04 11:03:25 183

原创 LeetCode算法题之31. Next Permutation(medium)

题目描述:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possi...

2020-04-03 11:48:23 148

原创 LeetCode算法题之27. Remove Element(easy)

题目描述:Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input...

2020-04-02 10:14:24 168

原创 LeetCode算法题之5. Longest Palindromic Substring(medium)

题目描述: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.Ex...

2020-04-01 16:11:52 116

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除