摘要: 1. 206. 反转链表输入:head = [1,2,3,4,5]输出:[5,4,3,2,1] class Solution(object): def reverseList(self, head): """ :type head: ListNode :rtype: ListNode """ pre 阅读全文
posted @ 2021-08-01 18:00 KIKI_FAN 阅读(31) 评论(0) 推荐(0) 编辑
摘要: Python数据类型不可变 int, float, string, tuple >>> a = 1>>> b = 1>>> print(id(a))140454796502904>>> print(id(b))140454796502904# a b 地址一样 >>> a = 1>>> x = co 阅读全文
posted @ 2021-08-01 17:20 KIKI_FAN 阅读(58) 评论(0) 推荐(0) 编辑
摘要: pre, nex = 0, 0 while pre < len(nums): if nums[pre] % 2 == 1: nums[pre], nums[nex] = nums[nex], nums[pre] nex += 1 pre += 1 return nums ''' l, r = 0, 阅读全文
posted @ 2021-07-28 19:24 KIKI_FAN 阅读(22) 评论(0) 推荐(0) 编辑
摘要: # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def 阅读全文
posted @ 2021-07-26 18:09 KIKI_FAN 阅读(26) 评论(0) 推荐(0) 编辑
摘要: class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ #有序-双指针 l, r = 0, len(nums) 阅读全文
posted @ 2021-07-26 17:27 KIKI_FAN 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 用两个栈实现一个队列。队列的声明如下,请实现它的两个函数 appendTail 和 deleteHead ,分别完成在队列尾部插入整数和在队列头部删除整数的功能。(若队列中没有元素,deleteHead 操作返回 -1 ) Solution class CQueue(object): def __i 阅读全文
posted @ 2021-07-03 16:59 KIKI_FAN 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 写一个函数,输入 n ,求斐波那契(Fibonacci)数列的第 n 项(即 F(N))。斐波那契数列的定义如下: F(0) = 0, F(1) = 1F(N) = F(N - 1) + F(N - 2), 其中 N > 1.斐波那契数列由 0 和 1 开始,之后的斐波那契数就是由之前的两数相加而得 阅读全文
posted @ 2021-07-03 16:53 KIKI_FAN 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效。 dic = {'{': '}', '[': ']', '(': ')'} stack = [] for c in s: if c in dic: stack.append(c) elif not s 阅读全文
posted @ 2021-06-30 22:04 KIKI_FAN 阅读(18) 评论(0) 推荐(0) 编辑
摘要: p1, p2 = m - 1, n - 1 tail = m + n - 1 while p1 >= 0 or p2 >= 0: if p1 == -1: nums1[tail] = nums2[p2] p2 -= 1 elif p2 == -1: nums1[tail] = nums1[p1] p 阅读全文
posted @ 2021-06-30 21:35 KIKI_FAN 阅读(26) 评论(0) 推荐(0) 编辑
摘要: Cucumber是一个 BDD 行为驱动开发的自动化测试工具 可以用自然的语言进行描述 Cucumber包括Features, Step_definitions, Cucumber command. 1. Features .feature文件 Feature: 对应test suite Scena 阅读全文
posted @ 2021-06-30 17:06 KIKI_FAN 阅读(328) 评论(0) 推荐(0) 编辑