LeetCode226. 翻转二叉树

LeetCode题目链接:https://leetcode.cn/problems/invert-binary-tree/题目叙述:给你一棵二叉树的根节点 root ,翻转这棵二叉树,并返回其根节点。 输入:root = [4,2,7,1,3,6,9]输出:[4,7,2,9,6,3,1] 示例 2: 输入:root = [2,1,3]输出:[2,3,1]示例 3:输入:root = []输出:[]...

LeetCode //C - 237. Delete Node in a Linked List

each node in the list is unique.The node to be deleted is in the list and is not a tail node. From: LeetCode Link: 237. Delete Node in a Linked List Solution: Ideas: Check for edge cases: The function first c...

LeetCode //C - 241. Different Ways to Add Parentheses

or ‘+’, ‘-’, and ‘*’.All the integer values in the input expression are in the range [0, 99]. From: LeetCode Link: 241. Different Ways to Add Parentheses Solution: Ideas: isSingleNumber Check: Added a functio...

LeetCode 0231】【位运算】2的N次方

Power of Two Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2^x. Example 1: **Input:** n = 1**O...

LeetCode:2956. 找到两个数组中的公共元素 + 模拟计数】

🍔 目录 🚩 题目链接⛲ 题目描述🌟 求解思路&实现代码&运行结果⚡ 模拟计数🥦 求解思路🥦 实现代码🥦 运行结果 💬 共勉 🚩 题目链接 2956. 找到两个数组中的公共元素 ⛲ 题目描述 给你两个下标从 0 开始的整数数组 nums1 和 nums2 ,它们分别含有 n 和 m 个元素。 请你计算以下两个数值: 统计 0 <= i < n 中的下标 i ,满足 nums1[i] 在 nums2 中 至少 出...

LeetCode:721. 账户合并 + 哈希表 + DFS】

🍔 目录 🚩 题目链接⛲ 题目描述🌟 求解思路&实现代码&运行结果⚡ 哈希表 + DFS🥦 求解思路🥦 实现代码🥦 运行结果 💬 共勉 🚩 题目链接 721. 账户合并 ⛲ 题目描述 给定一个列表 accounts,每个元素 accounts[i] 是一个字符串列表,其中第一个元素 accounts[i][0] 是 名称 (name),其余元素是 emails 表示该账户的邮箱地址。 现在,我们想合并这些账户。...

LeetCode 0051】【剪枝】N皇后

N-Queens The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. You...

leetcode-动态规划-01背包

一、二维数组 1、状态转移方程: 不放物品i:由dp[i - 1][j]推出,即背包容量为j,里面不放物品i的最大价值,此时dp[i][j]就是dp[i - 1][j]。(其实就是当物品i的重量大于背包j的重量时,物品i无法放进背包中,所以背包内的价值依然和前面相同。)放物品i:由dp[i - 1][j - weight[i]]推出,dp[i - 1][j - weight[i]] 为背包容量为j - weigh...

LeetCode 0102】【BSF】二叉树的层级遍历

Binary Tree Level Order Traversal Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level). Example 1: **Input:** root = [3,9,20,null...

Leetcode刷题4--- 寻找两个正序数组的中位数 Python

目录 题目及分析方法一:直接合并后排序方法二:二分查找法 题目及分析 (力扣序号4:[寻找两个正序数组的中位数](https://leetcode.cn/problems/median-of-two-sorted-arrays/description/) 给定两个大小分别为 m 和 n 的正序(从小到大)数组 nums1 和 nums2。请你找出并返回这两个正序数组的 中位数 。 示例 1: 输入:nums1 ...
© 2024 LMLPHP 关于我们 联系我们 友情链接 耗时0.013849(s)
2024-07-27 12:46:50 1722055610