题库 总和leetcode 39
[LeetCode] 2316. Count Unreachable Pairs of Nodes in an Undirected Graph
You are given an integer n. There is an undirected graph with n nodes, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i] ......
LeetCode 19 删除链表的倒数第N个节点
LeetCode 19 删除链表的倒数第N个节点 题目跳转链接 class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode* dummyHead=new ListNode(0); dumm ......
LeetCode 24. 两两交换链表中的节点
24. 两两交换链表中的节点 力扣题目跳转链接 具体解题思路和答案可以参考:代码随想录: 24. 两两交换链表中的节点 ####自我错误思考过程记录: ✘ 错误代码: //思路: class Solution { public: ListNode* swapPairs(ListNode* ......
力扣 216. 组合总和 III
216. 组合总和 III 找出所有相加之和为 n 的 k 个数的组合,且满足下列条件: 只使用数字1到9 每个数字 最多使用一次 返回 所有可能的有效组合的列表 。该列表不能包含相同的组合两次,组合可以以任何顺序返回。 示例 1: 输入: k = 3, n = 7 输出: [[1,2,4]] 解释 ......
【LeetCode动态规划#04】不同的二叉搜索树(找规律,有点像智力题)
不同的二叉搜索树 力扣题目链接(opens new window) 给定一个整数 n,求以 1 ... n 为节点组成的二叉搜索树有多少种? 示例: 思路 题意分析 先找一下关系 当n = 1时,如果元素就是1,以1为头节点 1 当n = 2时,分别以1和2为头节点 1 2 / \ 2 1 然后当n ......
LeetCode 59. 螺旋矩阵 II
这道题可以采用模拟法来实现。我们可以设置上下左右四个边界,然后模拟螺旋填充元素。具体来说,我们定义 left、right、top、bottom 四个变量代表当前需要填充的最左边、最右边、最上面、最下面的位置,然后根据当前位置,依次填充矩阵。 具体可以按照以下步骤实现: 初始化矩阵 matrix,并且 ......
Leetcode 17.电话号码的字母组合 (模拟)
题目链接在这里:电话号码的字母组合 这道题主要学习的是哈希表的应用:可以用大括号来代表建立哈希表,以及子函数的实现:可以直接在主函数中定义子函数,将$string$拼成一个整个的长$string:$"".join(list), 注意前面的这个空串是必要的,它代表子串之间直接相连,没有其他的字符。 f ......
Leetcode 15 & 16 (双指针)
都是比较经典的双指针问题,我们可以从中总结一些双指针的规律 首先这两题如果en做的话就是 $O(n^{3})$ 的算法,暴力去找。但是我们可以发现这三个值是满足一定约束的,所以考虑使用方法将它降到 $O(n^2)$ 。如果双指针,一个在头,一个在尾,两个向中间夹,根据约束条件合理选择向中间夹的策略, ......
kubelet.service: Failed with result 'exit-code'.
检查kubelet服务状态 systemctl status kubelet 检查journal日志 journalctl 的 -u 参数可以指定服务进行过滤,这样可以屏蔽掉其他无关日志。 --no-pager 参数可以一次性输出日志 journalctl -u ......
asp.net core3.1使用EF Core出现:'OFFSET' 附近有语法错误。 在 FETCH 语句中选项 NEXT 的用法无效
asp.net core 3.1 使用EF Core 3.1有毒 ef core 3.1遇到 sqlserver2008 'OFFSET' 附近有语法错误。\r\n在 FETCH 语句中选项 NEXT 的用法无效。 这就很烦,想加个EntityFrameworkCore.UseRowNumberFo ......
LeetCode|1630. 等差子数组
题目链接:1630. 等差子数组 难度中等60收藏分享切换为英文接收动态反馈 如果一个数列由至少两个元素组成,且每两个连续元素之间的差值都相同,那么这个序列就是 等差数列 。更正式地,数列 s 是等差数列,只需要满足:对于每个有效的 i , s[i+1] - s[i] == s[1] - s[0] ......
LeetCode60. 排列序列
class Solution { public: int fac[10]; void init() { fac[0]=1; fac[1]=1; for(int i=2;i<10;i++) fac[i]=fac[i-1]*i; return; } string str; bool visited[10 ......
代码随想录Day10-Leetcode232. 用栈实现队列,225. 用队列实现栈
### 232.用栈实现队列 尽管是很简单的一题, 但还是参考了题解, 一开始还在想,push的时候还得把输出栈倒回来效率好低 结果一看题解发现不用 //思路: 对对队列尾部操作时(push,empty), 对输入栈正常操作; 对队列头部操作时(peek,pop),全部弹出到输出栈中操作 //参考思 ......
L11U6-01 Talking about a book you've read
谈论故事 使用类似表达引入故事: I've just finished reading a really good book. 我刚刚看完了一本很不错的书。 It's about Elizabeth, an honest, lively, witty girl. 书中讲的是一个诚实、活泼而聪明的女孩 ......
How to log in when using gin's non-separated front-end and back-end systems
Person: How to log in when using gin's non-separated front-end and back-end systems? ChatGPT: When using Gin as the back-end system and a non-separate ......
【LeetCode动态规划#03】整数拆分(数学题)
整数拆分 力扣题目链接(opens new window) 给定一个正整数 n,将其拆分为至少两个正整数的和,并使这些整数的乘积最大化。 返回你可以获得的最大乘积。 示例 1: 输入: 2 输出: 1 解释: 2 = 1 + 1, 1 × 1 = 1。 示例 2: 输入: 10 输出: 36 解释: ......
What's default gateway?
What's default gateway? A default gateway is a network device that acts as an entry or exit point for traffic to and from a network. In other words, i ......
Python - str.strip() can strip '\n'
scnzzh: ~ >cat zzh.py print('aaa\n' + 'bbb') print('aaa\n'.strip() + 'bbb') scnzzh: ~ >python zzh.py aaa bbb aaabbb ......
代码随想录Day9-Leetcode28. 实现 strStr(),459.重复的子字符串
28. 实现 strStr() 这题之前写过, 而且印象深刻的是细节很多,所以这边是看完以前的代码,再写的(几乎是在背代码了hhh) 甚至这样, next[0]=-1, 和j开始匹配子串是没初始化成0这样的细节还是忘了 手撕kmp感觉光靠理解是有困难的 /** * @param {string} h ......
day25 打卡216.组合总和III 17.电话号码的字母组合
day25 打卡216.组合总和III 17.电话号码的字母组合 216.组合总和III 216题目链接 class Solution { List<List<Integer>> result = new ArrayList<>(); LinkedList<Integer> path = new L ......
代码随想录 day 25 216.组合总和III | 17.电话号码的字母组合
找出所有相加之和为 n 的 k 个数的组合。组合中只允许含有 1 - 9 的正整数,并且每种组合中不存在重复的数字。 说明: 所有数字都是正整数。 解集不能包含重复的组合。 示例 1: 输入: k = 3, n = 7 输出: [[1,2,4]] 示例 2: 输入: k = 3, n = 9 输出: ......
代码随想录Day8-Leetcode344.反转字符串 II,541. 反转字符串II ,剑指Offer 05.替换空格 ,151.翻转字符串里的单词,剑指Offer58-II.左旋转字符串
344. 反转字符串 题目链接:https://leetcode.cn/problems/reverse-string 明显的双指针 /** * @param {character[]} s * @return {void} Do not return anything, modify s in-p ......
Python - difference between '../../' and '/../../' when they are concatenated to a path
scnzzh: ~/aaa >cat zzh1.py import os.path print(os.path.dirname(__file__)) abs_file_dir = os.path.abspath(os.path.dirname(__file__)) print(abs_file_di ......
[LeetCode] 1032. Stream of Characters
Design an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of strings words. For ......
LeetCode——45. 跳跃游戏 II
LeetCode链接 45. 跳跃游戏 II 给定一个长度为 n 的 0 索引整数数组 nums。初始位置为 nums[0]。 每个元素 nums[i] 表示从索引 i 向前跳转的最大长度。换句话说,如果你在 nums[i] 处,你可以跳转到任意 nums[i + j] 处: 0 <= j <= n ......
Node12+ 下 axios 包使用报错引发的对 package.json's exports 等属性以及 esm 的探究
最近碰到一个 case,在一个用 ts 写的 node 项目里,使用 axios,本地开发没问题,但是部署上去报错了,然后使用方式改了一下就没问题了 import axios from 'axios' // 部署上去后报错 // 修改后 import axios from 'axios/dist/n ......
【LeetCode动态规划#02】图解不同路径I + II(首次涉及二维dp数组,)
不同路径 力扣题目链接(opens new window) 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为 “Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish” )。 问总共有多少条不同的路径? 示例 1: 输入 ......
LeetCode28. 找出字符串中第一个匹配项的下标
题目描述: 给你两个字符串 haystack 和 needle ,请你在 haystack 字符串中找出 needle 字符串的第一个匹配项的下标(下标从 0 开始)。 如果 needle 不是 haystack 的一部分,则返回 -1 。 示例 1: 输入:haystack = "sadbutsa ......
leetcode-1480-easy
Running Sum of 1d Array Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nu ......
leetcode-1450-easy
Number of Students Doing Homework at Given Time Given two integer arrays startTime and endTime and given an integer queryTime. The ith student started ......