leetcode column equal pairs
LeetCode | 19. 删除链表的倒数第 N 个结点
1 相关标签 链表、双指针、C 语言 2 报错情况 2.1 题目 给你一个链表,删除链表的倒数第 n 个结点,并且返回链表的头结点。 2.2 错误代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ......
LeetCode 1.两数之和
题目描述 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。 你可以按任意顺序返回答案。 示例 第一次提交的代码 impo ......
[Leetcode] 0088. 合并两个有序数组
88. 合并两个有序数组 题目描述 给你两个按 非递减顺序 排列的整数数组 nums1 和 nums2,另有两个整数 m 和 n ,分别表示 nums1 和 nums2 中的元素数目。 请你 合并 nums2 到 nums1 中,使合并后的数组同样按 非递减顺序 排列。 注意:最终,合并后数组不应由 ......
[Leetcode] 0824. 山羊拉丁文
824. 山羊拉丁文 题目描述 给你一个由若干单词组成的句子 sentence ,单词间由空格分隔。每个单词仅由大写和小写英文字母组成。 请你将句子转换为 “山羊拉丁文(Goat Latin)”(一种类似于 猪拉丁文 - Pig Latin 的虚构语言)。山羊拉丁文的规则如下: 如果单词以元音开头( ......
[Leetcode] 0821. 字符的最短距离
821. 字符的最短距离 题目描述 给你一个字符串 s 和一个字符 c ,且 c 是 s 中出现过的字符。 返回一个整数数组 answer ,其中 answer.length == s.length 且 answer[i] 是 s 中从下标 i 到离它 最近 的字符 c 的 距离 。 两个下标 i ......
leetcode102-二叉树层序遍历
目标:将每层的结果放在每层的集合中 问题:如何将不同父节点的同层节点,例如4和6,按照顺序放在一个list中 思路:4和6的关联在与它们的父节点,遍历他们的父节点时将其子节点放在一个缓存队列中,从队列中取值就能够实现目标 代码: 点击查看代码 class Solution { public List ......
[LeetCode] 147. Insertion Sort List_Middle tag: Linked List
Given the head of a singly linked list, sort the list using insertion sort, and return the sorted list's head. The steps of the insertion sort algorit ......
[LeetCode] 1356. Sort Integers by The Number of 1 Bits 根据数字二进制下1 的数目排序
You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case ......
Leetcode原题 -- 搜索旋转排序数组相关
第1题:33. 搜索旋转排序数组 题目描述:整数数组 nums 按升序排列,数组中的值 互不相同 。 在传递给函数之前,nums 在预先未知的某个下标 k(0 <= k < nums.length)上进行了 旋转,使数组变为 [nums[k], nums[k+1], ..., nums[n-1], ......
Leetcode原题 -- 螺旋矩阵相关
第一题:54. 螺旋矩阵 题目描述:给你一个 m 行 n 列的矩阵 matrix ,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。 示例 : 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 解题思路:按层遍历,如图所示,找到 ......
6.使用leetcode去练习语言
目录1 本章预览2 简单题举例2.1 题目描述2.2 题目解析2.3 题解2.4 涉及基础语法3 中等题举例3.1 题目描述3.2 题目解析3.3 题解3.4 涉及基础语法4 本章小结 1 本章预览 事实上本章并不会去讲述go语言的基础情况,而是去介绍如何使用Leetcode去帮助我们去学习go语言 ......
算法训练day39LeetCode738.968.
算法训练day39LeetCode738.968. 738.单调递增的数字 题目 738. 单调递增的数字 - 力扣(LeetCode) 题解 代码随想录 (programmercarl.com) class Solution { public: int monotoneIncreasingDigi ......
[LeetCode] 1726. Tuple with Same Product
Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements ......
Data structure - Sort & quick sort 小结及leetcode相关题目
Sort 主要有以下几种常见的sort, 面试中最有可能考的是quick sort, 关于k largest or 什么相关的。 Bubble sort Insertion sort Merge sort Quicksort Selection sort Counting sort Bucket s ......
算法训练day38 LeetCode435.763.56.
算法训练day38 LeetCode435.763.56. 435.无重叠区间 题目 435. 无重叠区间 - 力扣(LeetCode) 题解 代码随想录 (programmercarl.com) 首先按左边界排列范围 再将长的重叠区间去除 并记录去除个数 class Solution { publ ......
[Leetcode] 0083. 删除排序链表中的重复元素
83. 删除排序链表中的重复元素 题目描述 给定一个已排序的链表的头 head , 删除所有重复的元素,使每个元素只出现一次 。返回 已排序的链表 。 示例 1: 输入:head = [1,1,2] 输出:[1,2] 示例 2: 输入:head = [1,1,2,3,3] 输出:[1,2,3] 提示 ......
[Leetcode] 0070. 爬楼梯
70. 爬楼梯 题目描述 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 示例 1: 输入:n = 2 输出:2 解释:有两种方法可以爬到楼顶。 1. 1 阶 + 1 阶 2. 2 阶 示例 2: 输入:n = 3 输出:3 解 ......
leetcode338:比特位计数
今天刷力扣碰到了这道题,虽然是一道easy难度的题,但是感觉对位运算这块的算法很生疏,所以记录一下。 题目描述 给你一个整数 n ,对于 0 <= i <= n 中的每个 i ,计算其二进制表示中 1 的个数 ,返回一个长度为 n + 1 的数组 ans 作为答案。 示例1 输入:n = 2 输出: ......
Example: Pandas Excel output with column formatting pandas 对excel 列做格式处理
An example of converting a Pandas dataframe to an Excel file with column formats using Pandas and XlsxWriter. It isn’t possible to format any cells th ......
[LeetCode] 2525. Categorize Box According to Criteria
Given four integers length, width, height, and mass, representing the dimensions and mass of a box, respectively, return a string representing the cat ......
leetcode链表
class ListNode: def __init__(self, val=0, next=None): self.val = val #val表示值 self.next = next #指针next表示后继指针 class MyLinkedList: def __init__(self):#初始 ......
算法训练day37 LeetCode860.406.452.
算法训练day37 LeetCode860.406.452. 860.柠檬水找零 题目 860. 柠檬水找零 - 力扣(LeetCode) 题解 代码随想录 (programmercarl.com) 5:收五元 10:收十元,返五元 20:优先还十元+五元;否则还五元*3 class Solutio ......
[Leetcode] 0069. x 的平方根
69. x 的平方根 题目描述 给你一个非负整数 x ,计算并返回 x 的 算术平方根 。 由于返回类型是整数,结果只保留 整数部分 ,小数部分将被 舍去 。 注意:不允许使用任何内置指数函数和算符,例如 pow(x, 0.5) 或者 x ** 0.5 。 示例 1: 输入:x = 4 输出:2 示 ......
[Leetcode] 0067. 二进制求和
67. 二进制求和 题目描述 给你两个二进制字符串 a 和 b ,以二进制字符串的形式返回它们的和。 示例 1: 输入:a = "11", b = "1" 输出:"100" 示例 2: 输入:a = "1010", b = "1011" 输出:"10101" 提示: 1 <= a.length, b ......
CF1542E2 Abnormal Permutation Pairs (hard version) 题解
Abnormal Permutation Pairs (hard version) 两个限制:字典序小、逆序对大,一个显然的想法就是确保一对关系,统计另一对关系。 确保哪一对呢?我们想了想,决定确保字典序小,因为字典序是可以贪心的。 具体而言,我们考虑两个排列自第 \(i\) 位开始出现了不同。这样 ......
LeetCode142. 环形链表 II
题目描述 给定一个链表的头节点 head ,返回链表开始入环的第一个节点。 如果链表无环,则返回 null。 如果链表中有某个节点,可以通过连续跟踪 next 指针再次到达,则链表中存在环。 为了表示给定链表中的环,评测系统内部使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。如 ......
LeetCode02.07. 链表相交
描述 给你两个单链表的头节点 headA 和 headB ,请你找出并返回两个单链表相交的起始节点。如果两个链表没有交点,返回 null 。 示例 提交的代码 public class Solution { public ListNode getIntersectionNode(ListNode h ......
Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'jira.ji.ID' which is not functionally dependent on columns in GROUP BY clause;only_full_group_by
这个报错的完整信息 Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'jira.ji.ID' which is not functionally dependent on ......
LeetCode 42.接雨水
直觉来看,每一个正方形可以容纳1个单位的水。 按列来求,迭代求每一列可以容纳多少单位的水,累加。 找出每一列左右两边最高的柱子,遍历时,不用关注第一列和最后一列。然后找到两边最高中较小的柱子,与当前列高度比较,大于,则可以装水,其他不可以。 代码: class Solution { public i ......