leetcode possible binary trees

[LeetCode] 1979. Find Greatest Common Divisor of Array

Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums. The greatest common divisor of two ......
LeetCode Greatest Divisor Common Array

[LeetCode] 2807. Insert Greatest Common Divisors in Linked List

Given the head of a linked list head, in which each node contains an integer value. Between every pair of adjacent nodes, insert a new node with a val ......
LeetCode Greatest Divisors Insert Common

Maximum Depth of Binary Tree

Source Problem Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the rootnode down to ......
Maximum Binary Depth Tree of

leetcode 4. 寻找两个正序数组的中位数

leetcode 4. 寻找两个正序数组的中位数 第四题:寻找两个正序数组的中位数 1.合并数组,排序,找中位数 ​ 暴力解法,时间复杂度(M+N),空间复杂度(M+N) public double findMedianSortedArrays(int[] nums1, int[] nums2) { ......
中位数 数组 leetcode 两个

CF1527D MEX Tree 题解

思路 如果一条路径的 \(\text {mex} = k\),那么 \(0 \sim k-1\) 这些点一定在路径中出现过,并且一定在一条链上。如果不在一条链上,那么就不满足简单路径这一条件了。因此我们在从小到大加点的过程中如果发现一个点不在已求出的链上,那么比这个点编号大的 \(k\) 答案一定都 ......
题解 1527D 1527 Tree MEX

CF1017G The Tree

题意 给定一棵树和 \(3\) 个操作。 如果点 \(x\) 是白色,将她染红,否则对她地儿子做这个操作。 将点 \(x\) 子树内所有点染白。 询问 \(x\) 的颜色。 Sol 考虑对询问分块。 不难想到将当前块内的点建一棵虚树,然后再重构。 暴力建虚树即可。 Code #include <io ......
1017G 1017 Tree The CF

[ARC101E] Ribbons on Tree

[ARC101E] Ribbons on Tree Luogu ARC101E 题目描述 给定一个大小为 \(n\) 的树,保证 \(n\) 为偶数且小于 \(5000\) 您需要给树上的点两两配对,对于一组对子 \((u,v)\),在树上将 \(u\to v\) 的路径染色,定义一个配对方案合法当 ......
Ribbons 101E Tree ARC 101

Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

Launching lib/main.dart on 22011211C in debug mode... e: /Users/mm/.gradle/caches/transforms-3/37865fb99fa1fb60cf850910df4bb8bf/transformed/jetified-k ......

查看mvn版本:cannot execute binary file

一、现象 二、原因 网络资料上大部分的原因是因为jdk不是46位导致失败。其实我这边的原因也查不多,目前使用的是Mac M2芯片的电脑但是还安装之前的jdk版本,将其替换为macos arm版本即可。 三、操作 JDK下载官网下载、解压并更新环境变量 四、修复 ......
execute 版本 cannot binary file

分治法LeetCode经典例题(c语言解法)

多数元素https://leetcode.cn/problems/majority-element/description/ `//计数 int count(int* nums,int target,int left,int right){ int cnt = 0; for(int i = left ......
解法 例题 LeetCode 语言 经典

QTREE2 - Query on a tree II - solution

目录QTREE2 - Query on a tree II前置知识定义First. 求 \(dis_{u, v}\)Second. 求 \(u\) 到 \(v\) 路径上的第 \(k\) 个点时间复杂度Code QTREE2 - Query on a tree II \(\mathtt {TAGS} ......
solution QTREE2 QTREE Query tree

QTREE2 - Query on a tree II - solution

目录QTREE2 - Query on a tree II前置知识定义First. 求 \(dis_{u, v}\)Second. 求 \(u\) 到 \(v\) 路径上的第 \(k\) 个点时间复杂度Code QTREE2 - Query on a tree II \(\mathtt {TAGS} ......
solution QTREE2 QTREE Query tree

145. Binary Tree Postorder Traversal

public List<Integer> postorderTraversal(TreeNode root) { List<Integer> list = new ArrayList<>(); if (root == null) return list; Stack<TreeNode> stack ......
Postorder Traversal Binary Tree 145

144. Binary Tree Preorder Traversal

Solution 1://非递归 public List<Integer> preorderTraversal(TreeNode root) { List<Integer> result = new ArrayList<>(); if (root == null) { return result; ......
Traversal Preorder Binary Tree 144

P9678 [ICPC2022 Jinan R] Tree Distance

更好的阅读体验 P9678 [ICPC2022 Jinan R] Tree Distance 支配对,不是非常难。 显然如果 \(a\leq b<c\leq d\) 且 \(dis(a,d)>dis(b,c)\) 则点对 \((a,d)\) 是无用的,猜想点对数不会太多,事实也正是如此。 树上距离是 ......
Distance P9678 Jinan 9678 2022

ElementUI中el-tree-select使用

<el-tree-select multiple v-model="org" check-strictly :data="state.orgData" check-on-click-node :render-after-expand="false" :props="state.typeProps" ......
el-tree-select ElementUI select tree el

DSU on tree 学习笔记

DSU on tree 通常用来解决不带修树上子树问题。 主要思想: 剖分。 先搜轻儿子,记录轻儿子子树的答案,删去轻儿子的贡献。 搜重儿子,记录重儿子子树的答案,保留重儿子的贡献。 回溯,重新搜轻儿子,把轻儿子子树的贡献加上,构成本子树的答案。 CF600E Lomsat gelral #incl ......
笔记 tree DSU on

Leetcode 2982. 找出出现至少三次的最长特殊子字符串 II

开26个multiset,对于aabaaa,遍历,对第0个multiset push 1 2,然后对第一个multiset push 1,然后又对第0个multiset push 1 2,这时第0个multiset size超过3了,删除最小的元素,然后继续push 3,最后取 \(max_{i=1 ......
字符串 字符 Leetcode 2982 II

使用Cookie在VS Code中登录LeetCode插件

在VS Code的LeetCode插件中使用Cookie登录 1 在浏览器中打开leetcode网页并登录进去 2 按F12查看网页元素,找到graphql,查看其中的cookie,复制该cookie 3 在VS Code中点击登录leetcode的按钮,在登录方式中选择使用cookie登录,然后将 ......
插件 LeetCode Cookie Code

error: missing binary operator before token "(" 44 | #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE)

手痒,在centos7上面,升级了glibc,然后导致正常程序编译都出现了问题。 这是编译的报错: /opt/rh/devtoolset-9/root/usr/include/c++/9/x86_64-redhat-linux/bits/os_defines.h:44:19: error: miss ......
quot GLIBC_PREREQ GNU_SOURCE amp operator

P4897 【模板】最小割树(Gomory-Hu Tree)

题意 给定一张图,\(q\) 次询问,每次询问两点的最小割。 Sol 最小割树模板题。 考虑去分治一个集合 \(S\)。 每次在里面随便找两个点作为源点和汇点,然后在原图上跑最小割。 然后在残量网络上标记源点集和汇点集。 分别放到两个不同的集合,然后继续分治下去即可。 Code namespace ......
Gomory-Hu 模板 Gomory P4897 4897

leetcode 3.无重复字符的最长子串

leetcode 第三题:无重复字符的最长子串 自己写的: 第一想法:滑动窗口,用两个指针指向窗口的左右边界,用一个HashSet存储窗口内已有的值。另写一个find_first_temp方法用于出现重复字符时寻找新的左边界,左边界更新时也要更新set,将新左边界之前的元素删掉。 public in ......
字符 leetcode

leetcode 2.两数相加

leetcode 第二题:两数相加 以链表为载体模仿加法进位,同时遍历两个链表,逐位计算它们的和,并与当前位置的进位值相加。如果两个链表的长度不同,则可以认为长度短的链表的后面有若干个 0 。如果链表遍历结束后,有 carry>0,还需要在答案链表的后面附加一个节点,节点的值为 carry。 易错点 ......
leetcode

CF1254D Tree Queries

Tree Queries Luogu CF1254D 题面翻译 给定一棵 \(N\) 个节点的树,有 \(Q\) 次操作。 \(1\ v\ d\) 给定一个点 \(v\) 和一个权值 \(d\),等概率地选择一个点 \(r\),对每一个点 \(u\),若 \(v\) 在 \(u\) 到 \(r\) ......
Queries 1254D 1254 Tree CF

B - Christmas Trees

B - Christmas Trees https://atcoder.jp/contests/abc334/tasks/abc334_b 思路 对于起始种树点A 在 [L, R]区间的位置情况,三种 A < L A> R A>=L, A<=R Code https://atcoder.jp/con ......
Christmas Trees

leetcode 1.两数之和

leetcode 第一题:两数之和 1.暴力枚举: 最容易想到的方法是枚举数组中的每一个数 x,寻找数组中是否存在 target - x。 当我们使用遍历整个数组的方式寻找 target - x 时,需要注意到每一个位于 x 之前的元素都已经和 x 匹配过,因此不需要再进行匹配。而每一个元素不能被使 ......
之和 leetcode

--{module_name}_binary_host_mirror和--{module_name}_binary_site

--{module_name}_binary_host_mirror和--{module_name}_binary_site demo // .npmrc文件 sass_binary_site=https://npmmirror.com/mirrors/node-sass/ nodejieba_bi ......

CF1917F Construct Tree 题解

Description 给你一个数组 \(l_1,l_2,\dots.l_n\) 和一个数字 \(d\)。问你是否能够构造一棵树满足以下条件: 这棵树有 \(n+1\) 个点。 第 \(i\) 条边的长度是 \(l_i\)。 树的直径是 \(d\)。 只需要判断是否有解即可。 \(2\le n\le ......
题解 Construct 1917F 1917 Tree

leetcode 2706 购买两块巧克力

题目: 2706 购买两块巧克力 思路: 找两个最小值。 分情况讨论 代码 class Solution: def buyChoco(self, prices: List[int], money: int) -> int: # 遍历一遍,找2个最小值 # 找一个最小值我们都会。 # 找次小值,就分两 ......
巧克力 leetcode 2706

CF1917F Construct Tree 题解

题目链接:https://codeforces.com/contest/1917/problem/F 题意 有 \(n\) 条长度 \(l_i\) 的边,问它们是否能组成一棵 \(n + 1\) 个节点的树,使得树的直径长度为 \(d\)。\(n, d \le 2000\)。 题解 首先当然要存在一 ......
题解 Construct 1917F 1917 Tree
共2150篇  :2/72页 首页上一页2下一页尾页