上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 16 下一页
摘要: LeetCode58:https://leetcode-cn.com/problems/length-of-last-word/ 解题思路:利用字符串的内置函数 1 class Solution: 2 def lengthOfLastWord(self, s: str) -> int: 3 retu 阅读全文
posted @ 2021-02-19 11:53 vv_869 阅读(86) 评论(0) 推荐(0) 编辑
摘要: LeetCode35:https://leetcode-cn.com/problems/search-insert-position/ 解题思路:一种比较笨的方法,直接比较 # 先判断数字是否在给定的数组中 # 若在:遍历数组,找到该元素,并返回下标 # 若不在:遍历数组,比较大小,返回插入位置的索 阅读全文
posted @ 2021-02-18 18:41 vv_869 阅读(69) 评论(0) 推荐(0) 编辑
摘要: LeetCode28:https://leetcode-cn.com/problems/implement-strstr/submissions/ 解题思路:滑动窗法 1 class Solution: 2 def strStr(self, haystack: str, needle: str) - 阅读全文
posted @ 2021-02-18 16:52 vv_869 阅读(66) 评论(0) 推荐(0) 编辑
摘要: LeetCode27:27. 移除元素 - 力扣(LeetCode) (leetcode-cn.com) # 1 先对列表中需要移除的元素计数 # 2 移除该元素 1 class Solution: 2 def removeElement(self, nums: List[int], val: in 阅读全文
posted @ 2021-01-31 14:52 vv_869 阅读(77) 评论(0) 推荐(0) 编辑
摘要: LeetCode26 删除排序数组中的重复项 # 删除重复元素,解题方法:双指针 # 1 定义2个指针,慢指针i,从0开始;快指针j,从1开始 # 2 移动指针,如果当前nums[i] = nums[j],则j加1,i不动;如果不相等,则i,j均加1 1 class Solution: 2 def 阅读全文
posted @ 2021-01-30 22:45 vv_869 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 简单记录一下如何使用PyTorch实现线性回归的训练,代码如下: 1 # 导入所需的包 2 import torch 3 import numpy as np 4 import torch.utils.data as Data 5 import torch.nn as nn 6 from torch 阅读全文
posted @ 2021-01-29 22:19 vv_869 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 来源:https://www.kesci.com/mw/project/59f29f67c5f3f5119527a2cc 1. 导入numpy库并简写为 np 1 import numpy as np 2. 打印numpy的版本和配置说明 1 print(np.__version__) 2 np.s 阅读全文
posted @ 2021-01-28 22:19 vv_869 阅读(801) 评论(0) 推荐(0) 编辑
摘要: LeetCode14 最长公共前缀 链接:14. 最长公共前缀 - 力扣(LeetCode) (leetcode-cn.com) 解题思路: # 解题思路:把字符串数组的比较转换为2个字符串的比较 # 1通过比较字符串大小,确定最大值和最小值 # 2根据最小值的长度进行遍历,按位比较最大值和最小值, 阅读全文
posted @ 2021-01-26 22:20 vv_869 阅读(105) 评论(0) 推荐(0) 编辑
摘要: LeetCode13 罗马数字转整数 题目链接:https://leetcode-cn.com/problems/roman-to-integer/ 解题思路: # 1把罗马数字和对应的数值定义为字典; # 2计算输入字符的长度; # 3判断左边的数值是否小于右边,如果小于,则在总值中减去;反之加上 阅读全文
posted @ 2021-01-24 22:37 vv_869 阅读(117) 评论(0) 推荐(0) 编辑
摘要: LeetCode9 回文数 题目:https://leetcode-cn.com/problems/palindrome-number/ 解题思路如下: # 判断一个整数是否是回文数。 # 回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 # 1先判断,若为负,返回false; # 2 阅读全文
posted @ 2021-01-24 00:00 vv_869 阅读(98) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 16 下一页