Zum Hauptinhalt springen
LIVE
CVSS 8.7CVE-2026-138099 | A vulnerability was identified in Tenda AC10U 1.18.6. Affected by this vulnerability is the function readUsb of the component ATE Service. Such manipulation leads to out-of-bounds write. The attack can be executed remotely. The exploit is publicly available and might be used.CVSS 6.9CVE-2026-138098 | A vulnerability was determined in weison-tech yii2-cms up to 1.0.2. Affected is an unknown function of the file protected/core/config/common.php of the component RBAC Authorization. This manipulation causes improper authorization. Remote exploitation of the attack is possible.CVSS 6.9CVE-2026-138097 | A vulnerability was found in weison-tech yii2-cms up to 1.0.2. This impacts the function isActive of the file AccessControl.php of the component RBAC Admin Module. The manipulation results in missing authorization. The attack may be launched remotely.CVSS 6.9CVE-2026-138096 | A vulnerability has been found in weison-tech yii2-cms up to 1.0.2. This affects an unknown function of the file protected/core/config/web.php of the component Admin Auto-Login Identity Cookie. The manipulation leads to improper authentication. The attack may be initiated remotely.CVSS 4.8CVE-2026-138094 | A security vulnerability has been detected in ggml-org llama.cpp up to 0.6.0. Impacted is the function ggml_acc_impl of the file ggml/src/ggml.c of the component ggml Handler. Such manipulation leads to numeric truncation error. The attack can only be performed from a local environment. Upgrading to version 0.7.0 is recommended to address this issue. The name of the patch is 8ae386707bed05f02354dbfc6fa5ee0cf58e5f0f. It is recommended to upgrade the affectedCVSS 6.9CVE-2026-138093 | A weakness has been identified in alexander-torosh yona-cms up to 0.5.0. This issue affects the function loginAction of the file app/modules/Admin/Controller/IndexController.php of the component Admin Login Endpoint. This manipulation causes sql injection. It is possible to initiate the attack remotely.CVSS 4.8CVE-2026-138092 | A security flaw has been discovered in ggml-org llama.cpp up to 0.8.0. This vulnerability affects the function ggml_roll of the file ggml/src/ggml.c of the component Ggml Tensor Library Roll Operation. The manipulation results in integer overflow. The attack needs to be approached locally. Upgrading to version 0.9.0 is able to resolve this issue. The patch is identified as 0978a6e9022fb9bd6874b86154ee304e81929b9f. It is suggested to upgrade the affected compCVSS 10.0CVE-2026-138091 | A vulnerability was identified in Tenda AC10U 15.03.06.48. This affects the function TendaTelnet of the file /goform/telnet of the component Web UI. The manipulation leads to missing authentication. The attack is possible to be carried out remotely. The exploit is publicly available and might be used.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

Maximum Width of Binary Tree

Given the root of a binary tree, return the **## Problem Statement Given the root of a binary tree, return the maximum width of the tree. The width of a level…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 6 Min. Lesezeit
Quelle: dev.to
Rubrik: Programmation sécurisée

Given the root of a binary tree, return the **## Problem Statement



Given the root of a binary tree, return the maximum width of the tree.



The width of a level is defined as:




Distance between the leftmost
and rightmost non-null nodes
(including null nodes in between).












Brute Force Intuition



In an interview, you can explain it like this:




Perform a level-order traversal and count the number of nodes at each level.




However, this is incorrect because missing (null) nodes between two existing nodes also contribute to the width.



Example:




        1
/ \
2 3
/ \
4 5






Level 3 has only two nodes,



but its width is:




4






not 2.









Complexity




  • Time Complexity: O(N)

  • Space Complexity: O(N)









Moving Towards the Optimal Approach



Treat the binary tree as if it were stored in an array.



Assign every node an index.



Rules:




Root → 0






For every node:




Left Child

↓

2 * index + 1









Right Child

↓

2 * index + 2






Now,



Width of a level becomes:




Last Index

-

First Index

+

1












Pattern Recognition



Whenever you see:




  • Width of Binary Tree

  • Complete Binary Tree Positioning



Think:



Level Order Traversal + Indexing









Key Observation



Store inside the queue:




(Node, Index)






For every level:




First Index

↓

Last Index






Width:




last - first + 1;






To prevent integer overflow,



normalize indices at every level.









Optimal Approach






Step 1



Perform BFS.



Queue stores:




(Node, Index)












Step 2



For every level,



store:




Minimum Index






Subtract it from every index.



This keeps numbers small.









Step 3



Track:




First Index

↓

Last Index












Step 4



Update answer:




last - first + 1;












Optimal Java Solution






class Pair {

TreeNode node;
int index;

Pair(TreeNode node, int index) {

this.node = node;
this.index = index;
}
}

class Solution {

public int widthOfBinaryTree(TreeNode root) {

if (root == null)
return 0;

Queue<Pair> q = new LinkedList<>();

q.offer(new Pair(root, 0));

int ans = 0;

while (!q.isEmpty()) {

int size = q.size();

int minIndex = q.peek().index;

int first = 0;
int last = 0;

for (int i = 0; i < size; i++) {

Pair curr = q.poll();

int index = curr.index - minIndex;

if (i == 0)
first = index;

if (i == size - 1)
last = index;

if (curr.node.left != null)

q.offer(new Pair(
curr.node.left,
2 * index + 1));

if (curr.node.right != null)

q.offer(new Pair(
curr.node.right,
2 * index + 2));
}

ans = Math.max(ans,
last - first + 1);
}

return ans;
}
}












Dry Run






          1
/ \
2 3
/ \
4 5






Assign indices:




          0
/ \
1 2
/ \
3 6












Level 1



Indices:




0






Width:




1












Level 2



Indices:




1

2






Width:




2












Level 3



Indices:




3

6






Width:




6 - 3 + 1

=

4






Answer:




4












Why Indexing Works?



The assigned indices represent the positions of nodes in a complete binary tree.



Even if some nodes are missing,



their positions are preserved.



Thus,




Last Index

-

First Index

+

1






correctly measures the actual width.









Complexity Analysis




















Metric Complexity
Time Complexity O(N)
Space Complexity O(N)








Interview One-Liner




Perform a level-order traversal while assigning complete binary tree indices to each node. The width of each level is the difference between the first and last indices plus one.










Pattern Learned






Level Order

↓

Assign Indices

↓

First Index

↓

Last Index

↓

Maximum Width









Similar Problems




  • Maximum Width of Binary Tree

  • Complete Binary Tree

  • Left View

  • Right View

  • Vertical Order Traversal









Memory Trick



Think:




Root → 0

↓

Left = 2i + 1

↓

Right = 2i + 2

↓

Width

=

Last - First + 1









Mental Model






BFS

↓

(Node, Index)

↓

Track First & Last

↓

Update Maximum Width






Whenever you hear:




"Maximum Width of Binary Tree"




your brain should immediately think:



Level Order Traversal + Complete Binary Tree Indexing .



The width of a level is defined as:




Distance between the leftmost
and rightmost non-null nodes
(including null nodes in between).












Brute Force Intuition



In an interview, you can explain it like this:




Perform a level-order traversal and count the number of nodes at each level.




However, this is incorrect because missing (null) nodes between two existing nodes also contribute to the width.



Example:




        1
/ \
2 3
/ \
4 5






Level 3 has only two nodes,



but its width is:




4






not 2.









Complexity




  • Time Complexity: O(N)

  • Space Complexity: O(N)









Moving Towards the Optimal Approach



Treat the binary tree as if it were stored in an array.



Assign every node an index.



Rules:




Root → 0






For every node:




Left Child

↓

2 * index + 1









Right Child

↓

2 * index + 2






Now,



Width of a level becomes:




Last Index

-

First Index

+

1












Pattern Recognition



Whenever you see:




  • Width of Binary Tree

  • Complete Binary Tree Positioning



Think:



Level Order Traversal + Indexing









Key Observation



Store inside the queue:




(Node, Index)






For every level:




First Index

↓

Last Index






Width:




last - first + 1;






To prevent integer overflow,



normalize indices at every level.









Optimal Approach






Step 1



Perform BFS.



Queue stores:




(Node, Index)












Step 2



For every level,



store:




Minimum Index






Subtract it from every index.



This keeps numbers small.









Step 3



Track:




First Index

↓

Last Index












Step 4



Update answer:




last - first + 1;












Optimal Java Solution






class Pair {

TreeNode node;
int index;

Pair(TreeNode node, int index) {

this.node = node;
this.index = index;
}
}

class Solution {

public int widthOfBinaryTree(TreeNode root) {

if (root == null)
return 0;

Queue<Pair> q = new LinkedList<>();

q.offer(new Pair(root, 0));

int ans = 0;

while (!q.isEmpty()) {

int size = q.size();

int minIndex = q.peek().index;

int first = 0;
int last = 0;

for (int i = 0; i < size; i++) {

Pair curr = q.poll();

int index = curr.index - minIndex;

if (i == 0)
first = index;

if (i == size - 1)
last = index;

if (curr.node.left != null)

q.offer(new Pair(
curr.node.left,
2 * index + 1));

if (curr.node.right != null)

q.offer(new Pair(
curr.node.right,
2 * index + 2));
}

ans = Math.max(ans,
last - first + 1);
}

return ans;
}
}












Dry Run






          1
/ \
2 3
/ \
4 5






Assign indices:




          0
/ \
1 2
/ \
3 6












Level 1



Indices:




0






Width:




1












Level 2



Indices:




1

2






Width:




2












Level 3



Indices:




3

6






Width:




6 - 3 + 1

=

4






Answer:




4












Why Indexing Works?



The assigned indices represent the positions of nodes in a complete binary tree.



Even if some nodes are missing,



their positions are preserved.



Thus,




Last Index

-

First Index

+

1






correctly measures the actual width.









Complexity Analysis




















Metric Complexity
Time Complexity O(N)
Space Complexity O(N)








Interview One-Liner




Perform a level-order traversal while assigning complete binary tree indices to each node. The width of each level is the difference between the first and last indices plus one.










Pattern Learned






Level Order

↓

Assign Indices

↓

First Index

↓

Last Index

↓

Maximum Width









Similar Problems




  • Maximum Width of Binary Tree

  • Complete Binary Tree

  • Left View

  • Right View

  • Vertical Order Traversal









Memory Trick



Think:




Root → 0

↓

Left = 2i + 1

↓

Right = 2i + 2

↓

Width

=

Last - First + 1









Mental Model






BFS

↓

(Node, Index)

↓

Track First & Last

↓

Update Maximum Width






Whenever you hear:




"Maximum Width of Binary Tree"




your brain should immediately think:



Level Order Traversal + Complete Binary Tree Indexing

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Discussion communautaire et commentaires

🌐 Rejoindre le chat principal

Lancez la discussion dans le flux diffusé du Social Chat ou proposez ci-dessus une contribution experte via le formulaire de complément.

Évaluation communautaire &amp; preuve sociale
⭐ Avis des lecteurs
–
Ø / 5.0
Pas encore d'évaluation des lecteurs
Cet article vous a-t-il été utile ?
0
Donner votre évaluation
Évaluation détaillée (facultatif)
Contenu & qualité
Source & fiabilité
Actualité
Briefing sécurité Gratuit · désabonnement en 1 clic

Intelligence Digest — gratuit

Chaque jour, les principales actualités sécurité · résiliable à tout moment

Groupes d’histoires apparentées & sources (IA vectorielle)

6 Cluster
23 sources
CVE-2026-72239 | Linux Kernel sev x86/virt/sev/sev.c wbinvd_on_all_cpus state issue (WID-SEC-2026-2852)
VulDB Updates il y a 32 min.
22 autres sources
VulDB Updatesil y a 32 min.CVE-2026-72240 | Linux Kernel up to 7.1.4 mfd sm501_register_device memory leak (WID-SEC-2026-2852) VulDB Updatesil y a 32 min.CVE-2026-72241 | Linux Kernel up to 7.1.4 uleds strchr buffer overflow (WID-SEC-2026-2852) VulDB Updatesil y a 32 min.CVE-2026-72244 | Linux Kernel up to 6.12.100/6.18.41/7.1.4/7.2-rc2 gpu-buddy allocation of resources (WID-SEC-2026-2852) VulDB Updatesil y a 32 min.CVE-2026-72243 | Linux Kernel up to 7.2-rc2 selinux socket_sendmsg permission (Nessus ID 364200 / WID-SEC-2026-2852) VulDB Updatesil y a 32 min.CVE-2026-72245 | Linux Kernel up to 7.1.4 host1x host1x_device_parse_dt release of resource (WID-SEC-2026-2852) VulDB Updatesil y a 32 min.CVE-2026-72246 | Linux Kernel flowtable input validation (WID-SEC-2026-2852) VulDB Updatesil y a 32 min.CVE-2026-72247 | Linux Kernel up to 7.2-rc3 nf_conncount __nf_conncount_add dir comparison (WID-SEC-2026-2852) VulDB Updatesil y a 32 min.CVE-2026-72248 | Linux Kernel up to 7.1.4/7.2-rc2 flowtable nft_flow_dst_release buffer overflow (WID-SEC-2026-2852) LinuxAndUbuntuil y a 50 min.Linux AutoFDO Benchmark: Clang Kernel Optimization VulDB Updatesil y a 1 hCVE-2022-31607 | NVIDIA GPU Display Driver on Linux Kernel Mode Layer nvidia.ko input validation (EUVD-2022-53059 / Nessus ID 339047) VulDB Updatesil y a 2 hCVE-2026-72227 | Linux Kernel up to 6.12.96/6.18.39/7.1.4/7.2-rc2 batman-adv out-of-bounds (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72228 | Linux Kernel up to 7.2-rc2 batman-adv skb_split memory leak (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72229 | Linux Kernel up to 7.2-rc2 batman-adv register_netdevice memory leak (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72231 | Linux Kernel up to 7.2-rc2 batman-adv batadv_send_tt_request allocation of resources (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72230 | Linux Kernel up to 7.2-rc2 batman-adv batadv_frag_send_packet memory leak (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72232 | Linux Kernel up to 7.2-rc2 batman-adv batadv_interface_tx out-of-bounds (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72234 | Linux Kernel up to 7.2-rc1 batman-adv batadv_get_vid use after free (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72233 | Linux Kernel up to 7.2-rc1 batman-adv batadv_bla_is_backbone_gw use after free (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72236 | Linux Kernel up to 7.2-rc3 s390/perf_cpum_cf __hw_perf_event_init config array index (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72235 | Linux Kernel up to 7.2-rc1 batman-adv batadv_interface_rx use after free (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72237 | Linux Kernel up to 7.2-rc2 BRS /x86/amd/brs amd_brs_match_plm information disclosure (WID-SEC-2026-2852) VulDB Updatesil y a 2 hCVE-2026-72238 | Linux Kernel up to 7.2-rc3 x86 boot early_serial_init integer overflow (WID-SEC-2026-2852)
13 sources
Cyber Monday Meta Quest 3S Deal Knocks $53 Off and Gets You $50 Free Amazon Credit
CNET il y a 12 min.
12 autres sources
Articles similaires
🔍 Verwandte News

Auch interessante Nachrichten Maximum Width of Binary Tree

Thematisch verwandte Begriffe: Maximum, Width, Binary, Tree · 6 Treffer

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

💬 Chargement des commentaires…
Sentinel CTI: ONLINE
Tirer pour actualiser
Widgets & sujets
Chargement des widgets…
Article suivant