上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 22 下一页
摘要: 请你来实现一个 atoi 函数,使其能将字符串转换成整数。(前两个我写的,效率不是很高) class Solution(object): def myAtoi1(self, s): """ :type s: str :rtype: int """ temp = s.strip() if not te 阅读全文
posted @ 2021-01-12 16:34 楠海 阅读(105) 评论(0) 推荐(0)
摘要: 给你一个整数数组 nums ,设计算法来打乱一个没有重复元素的数组。(这个我写的,但是我感觉用别人的随机算法是挺好,但是就是不知道原理) class Solution(object): def __init__(self, nums): """ :type nums: List[int] """ s 阅读全文
posted @ 2021-01-12 11:15 楠海 阅读(73) 评论(0) 推荐(0)
摘要: 给定一个整数,写一个函数来判断它是否是 3 的幂次方。如果是,返回 true ;否则,返回 false 。(第一个我写的) class Solution(object): def isPowerOfThree1(self, n): """我的偷懒解法 :type n: int :rtype: boo 阅读全文
posted @ 2021-01-11 11:09 楠海 阅读(75) 评论(0) 推荐(0)
摘要: 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。(第二个不是我写的其他的都两个是我写的) class Solution(object): def isPalindrome1(self, s): """ :type s: str :rtype: bool """ len 阅读全文
posted @ 2021-01-08 18:09 楠海 阅读(61) 评论(0) 推荐(0)
摘要: 给定一个 n × n 的二维矩阵表示一个图像。将图像顺时针旋转 90 度。(这次没有抄,都是我写的) class Solution(object): def rotate1(self, matrix): """ :type matrix: List[List[int]] :rtype: None D 阅读全文
posted @ 2021-01-08 16:18 楠海 阅读(63) 评论(0) 推荐(0)
摘要: 统计所有小于非负整数 n 的质数的数量。 (前三个我写的[其实就以前看过]超时了,后面自己想吧) class Solution(object): def countPrimes1(self, n): """ :type n: int :rtype: int """ if n <= 2: return 阅读全文
posted @ 2021-01-07 17:09 楠海 阅读(98) 评论(0) 推荐(0)
摘要: 判断一个 9x9 的数独是否有效。只需要根据以下规则,验证已经填入的数字是否有效即可。(第一个我写的,暴力匹配,脑子不够直接暴力来.) class Solution(object): def isValidSudoku2(self, board): """ :type board: List[Lis 阅读全文
posted @ 2021-01-07 14:24 楠海 阅读(69) 评论(0) 推荐(0)
摘要: 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。(第一个我写的时间太长) # Definition for singly-linked list. class ListNode(object): def __init__(self, val=0, next=None): self. 阅读全文
posted @ 2021-01-06 16:26 楠海 阅读(54) 评论(0) 推荐(0)
摘要: django中关于跨域访问设置 记一次 CORS 跨域请求出现 OPTIONS 请求的问题及解决方法 今天前后端在联调接口的时候,发生了跨域请求资源获取不到的问题。 首先说明下跨域问题的由来。引自HTTP 访问控制 的一段话: 当 Web 资源请求由其它域名或端口提供的资源时,会发起跨域 HTTP 阅读全文
posted @ 2021-01-06 16:10 楠海 阅读(214) 评论(0) 推荐(0)
摘要: 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。(第一个我写的,后面自己猜) class Solution(object): def moveZeroes1(self, nums: list): """ :type nums: List[int] :rt 阅读全文
posted @ 2021-01-06 14:28 楠海 阅读(128) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 22 下一页