随笔分类 - LeetCode
今天不想题,明日更垃圾
摘要:题目描述: https://leetcode.cn/problems/reverse-nodes-in-k-group 给你链表的头节点 head ,每 k 个节点一组进行翻转,请你返回修改后的链表。 k 是一个正整数,它的值小于或等于链表的长度。如果节点总数不是 k 的整数倍,那么请将最后剩余的节
阅读全文
摘要:题目描述: https://leetcode.cn/problems/reverse-linked-list-ii 给你单链表的头指针 head 和两个整数 left 和 right ,其中 left <= right 。请你反转从位置 left 到位置 right 的链表节点,返回 反转后的链表
阅读全文
摘要:题目描述: https://leetcode.cn/problems/swap-nodes-in-pairs/ 给你一个链表,两两交换其中相邻的节点,并返回交换后链表的头节点。你必须在不修改节点内部的值的情况下完成本题(即,只能进行节点交换)。 示例 1: 输入:head = [1,2,3,4] 输
阅读全文
摘要:There is a function signFunc(x) that returns: 1 if x is positive. -1 if x is negative. 0 if x is equal to 0. You are given an integer array nums. Let
阅读全文
摘要:You are given an array points where points[i] = [xi, yi] is the coordinates of the ith point on a 2D plane. Multiple points can have the same coordina
阅读全文
摘要: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 nums. Example 1: Input: nu
阅读全文
摘要:Given an m x n matrix, return all elements of the matrix in spiral order. Example 1: Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,3,6,9,8,7,
阅读全文
摘要:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the lef
阅读全文
摘要:Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. Follow up: Could you implement a solution
阅读全文
摘要:Given a binary tree, return the sum of values of nodes with even-valued grandparent. (A grandparent of a node is the parent of its parent, if it exist
阅读全文
摘要:Given two binary search trees root1 and root2. Return a list containing all the integers from both trees sorted in ascending order. Example 1: Input:
阅读全文
摘要:1323. Maximum 69 Number Easy 56289Add to ListShare Given a positive integer num consisting only of digits 6 and 9. Return the maximum number you can g
阅读全文
摘要:Given a binary search tree, return a balanced binary search tree with the same node values. A binary search tree is balanced if and only if the depth
阅读全文
摘要:Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1, and return them in any ord
阅读全文
摘要:There is an m x n matrix that is initialized to all 0's. There is also a 2D array indices where each indices[i] = [ri, ci] represents a 0-indexed loca
阅读全文
摘要:1、数组a中一组数(a[i]只能是0或者1),0变成1,1变成0,怎样操作?比如,lt 832题 答:a[i]与1进行异或运算(异或运算:不同为真,相同为假) 2、判断一个数是奇数还是偶数?比如,lt 1342题 一个数的二进制从右向左的与1进行&运算,结果为0,则这个十进制数是偶数,结果为1,则这
阅读全文
摘要:Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means t
阅读全文
摘要:A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase an
阅读全文
摘要:给你一个单链表的引用结点 head。链表中每个结点的值不是 0 就是 1。已知此链表是一个整数数字的二进制表示形式。 请你返回该链表所表示数字的 十进制值 。 示例 输入:head = [1,0,1]输出:5解释:二进制数 (101) 转化为十进制数 (5) 方法一:二进制转换成十进制(res初值为
阅读全文
摘要:给你一棵二叉树,请你返回层数最深的叶子节点的和。 示例: 输入:root = [1,2,3,4,5,null,6,7,null,null,null,null,8]输出:15 来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/deepest-leav
阅读全文

浙公网安备 33010602011771号