• leetcode48 旋转图像

    时间:2024-04-28 21:52:04

      class Solution: def rotate(self, matrix: List[List[int]]) -> None: n = len(matrix) for i in range(n // 2): for j in r...

  • Leetcode—1017. 负二进制转换【中等】(string列表初始化、反向迭代器)

    时间:2024-04-28 19:29:41

    2024每日刷题(120) Leetcode—1017. 负二进制转换 实现代码 class Solution {public: string baseNeg2(int n) { string ans; while(n != 0) { ans...

  • 【一天一道LeetCode】#76. Minimum Window Substring

    时间:2024-04-28 18:40:42

    一天一道LeetCode本系列文章已全部上传至我的github,地址:ZeeCoder‘s Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处(一)题目Given a string S and a string T, find the minimum window...

  • leetcode58 最后一个单词的长度

    时间:2024-04-28 14:48:47

    给你一个字符串 s,由若干单词组成,单词前后用一些空格字符隔开。返回字符串中 最后一个 单词的长度。 单词 是指仅由字母组成、不包含任何空格字符的最大 子字符串。 示例 1: 输入:s = "Hello World"输出:5解释:最后一个单词是“World”,长度为 5。 示例 2: 输入:s = ...

  • LeetCode 每日一题 ---- 【2739.总行驶距离】

    时间:2024-04-28 07:19:10

    LeetCode 每日一题 ---- 【2739.总行驶距离】 2739.总行驶距离解题方法:模拟 2739.总行驶距离 解题方法:模拟 根据题意进行模拟,主邮箱每减少 5 升油,汽车就可以行驶 10 公里,同时副油箱需要向主油箱注入 1 升油,需要注意的是,副油箱中的油可能会出现不足的情...

  • 递推入门,LeetCode 377. 组合总和 Ⅳ

    时间:2024-04-28 07:17:45

    一、题目 1、题目描述 给你一个由 不同 整数组成的数组 nums ,和一个目标整数 target 。请你从 nums 中找出并返回总和为 target 的元素组合的个数。 题目数据保证答案符合 32 位整数范围。 2、接口描述 python3 ​ class Solution: de...

  • leetcode104

    时间:2024-04-28 00:04:15

    /** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * ...

  • Java for LeetCode 237 Delete Node in a Linked List

    时间:2024-04-27 22:36:10

    Java实现如下:public class Solution { public void deleteNode(ListNode node) { if(node==null||node.next==null) return; node.val = no

  • LeetCode 237. Delete Node in a Linked List (在链表中删除一个点)

    时间:2024-04-27 22:29:51

    Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 ->...

  • 【LeetCode】237. Delete Node in a Linked List 解题报告 (Java&Python&C++)

    时间:2024-04-27 22:21:11

    作者: 负雪明烛id: fuxuemingzhu个人博客:http://fuxuemingzhu.cn/目录题目描述题目大意解题方法设置当前节点的值为下一个日期[LeetCode]题目地址:https://leetcode.com/problems/delete-node-in-a-linked-l...

  • Python | Leetcode Python题解之第51题N皇后-题解:

    时间:2024-04-27 22:17:17

    class Solution: def solveNQueens(self, n: int) -> List[List[str]]: def generateBoard(): board = list() for i in ra...

  • LeetCode Array Easy 283. Move Zeroes

    时间:2024-04-27 22:14:44

    DescriptionGiven an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.Exampl...

  • [LeetCode] 237. Delete Node in a Linked List 解题思路

    时间:2024-04-27 21:44:25

    Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 ->...

  • 【一天一道LeetCode】#237. Delete Node in a Linked List

    时间:2024-04-27 21:39:11

    一天一道LeetCode本系列文章已全部上传至我的github,地址:ZeeCoder‘s Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处(一)题目Write a function to delete a node (except the tail) in a...

  • [LeetCode] 237. Delete Node in a Linked List 删除链表的节点

    时间:2024-04-27 21:39:25

    Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Given linked list -- head = [4,5,1,9], whi...

  • 每日两题 / 234. 回文链表 && 21. 合并两个有序链表(LeetCode热题100)

    时间:2024-04-27 19:49:14

    234. 回文链表 - 力扣(LeetCode) 先创建一个指针指向第一个节点 dfs到最后一个节点,开始与第一个节点进行比较 class Solution {public: ListNode *t; bool dfs(ListNode *cur) { if (cur...

  • leetcode-二叉树的镜像-91

    时间:2024-04-26 17:14:15

    /** * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * TreeNode(int x) : val(x), left(nullptr), r...

  • 【链表】Leetcode 两数相加-算法讲解

    时间:2024-04-26 07:36:36

    我们这里设置一个头结点,然后遍历两个链表,使用一个flag记录相加的结果和进位,如果两个链表没有走到最后或者进位不等于0,我们就继续遍历处理进位;如果当前的链表都遍历完成了,判断当前的进位是否>10,然后处理是否需要添加进位结点 /** * Definition for singly-lin...

  • 【Leetcode每日一题】 分治 - 数组中的第K个最大元素(难度⭐⭐)(63)

    时间:2024-04-25 07:33:46

    1. 题目解析 题目链接:数组中的第K个最大元素 这个问题的理解其实相当简单,只需看一下示例,基本就能明白其含义了。 2.算法原理 在快速排序算法中,一种常见的优化策略是将数组划分为三个区间。这种划分方式可以更加精确地定位到目标元素所在的位置,从而加快排序速度。具体地,这三个区间为:[l, lef...

  • Leetcode 第394场周赛 问题和解法-题目

    时间:2024-04-25 07:17:32

    统计特殊字母的数量 I 给你一个字符串word。如果word中同时存在某个字母的小写形式和大写形式,则称这个字母为特殊字母。 返回word中特殊字母的数量。 示例 1: 输入:word = "aaAbcBC"输出:3解释:word 中的特殊字母是 'a'、'b' 和 'c'。 解题思路 创建两个数...