Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Windows Tipps & SecurityNighthawk M7 Pro im Test: Flexibler, aber teurer 5G-Router(21.09.2026 um 10:30 Uhr)
Sichere ProgrammierungNeue Gmail-Funktion: So sparst du jetzt Zeit bei Einmalcodes(21.09.2026 um 10:00 Uhr)
Sichere ProgrammierungYour GIF exporter is fine — the container is the problem(21.09.2026 um 10:01 Uhr)
Sichere ProgrammierungCSS, Motion, or GSAP? I Choose by Who Owns the Animation(21.09.2026 um 10:12 Uhr)
Windows Tipps & SecurityNighthawk M7 Pro im Test: Flexibler, aber teurer 5G-Router(21.09.2026 um 10:30 Uhr)
Sichere ProgrammierungNeue Gmail-Funktion: So sparst du jetzt Zeit bei Einmalcodes(21.09.2026 um 10:00 Uhr)
Sichere ProgrammierungYour GIF exporter is fine — the container is the problem(21.09.2026 um 10:01 Uhr)
Sichere ProgrammierungCSS, Motion, or GSAP? I Choose by Who Owns the Animation(21.09.2026 um 10:12 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

LeetCode Day 12

144. Binary Tree Preorder Traversal Use iteration instead of recursion public List<Integer> preorderTraversal(TreeNode root) { List<Integer> list = new ArrayList<>(); //mid -> left…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




144. Binary Tree Preorder Traversal






Use iteration instead of recursion






    public List<Integer> preorderTraversal(TreeNode root) {
List<Integer> list = new ArrayList<>();
//mid -> left -> right
Deque<TreeNode> stack = new LinkedList<>();
stack.push(root);

while(!stack.isEmpty()){
TreeNode cur = stack.pop();
if(cur!=null){
list.add(cur.val);
stack.push(cur.right);
stack.push(cur.left);
}
}

return list;
}









LeetCode No. 226. Invert Binary Tree



Given the root of a binary tree, invert the tree, and return its root.



Example 1:



Image description




Input: root = [4,2,7,1,3,6,9]

Output: [4,7,2,9,6,3,1]




Example 2:



Example 2:

Image description




Input: root = [2,1,3]

Output: [2,3,1]




Example 3:




Input: root = []

Output: []




Constraints:



The number of nodes in the tree is in the range [0, 100].

-100 <= Node.val <= 100





BFS, Iteration ways





    public TreeNode invertTree(TreeNode root) {
if(root == null){
return null;
}
TreeNode cur = root;
Deque<TreeNode> queue = new ArrayDeque<>();
queue.offer(cur);

while(!queue.isEmpty()){
if(cur!=null){
cur = queue.poll();
TreeNode temp = cur.left;
cur.left = cur.right;
cur.right = temp;
if(cur.left != null){
queue.offer(cur.left);
}
if(cur.right !=null){
queue.offer(cur.right);
}

}
}
return root;

}







Refine It



Image description

Here this evaluation is useless because if the element is in queue it must be non-null (We use offer() to add elements and it will cause NullPointer Exception it offered elements are null)





LeetCode No. 101. Symmetric Tree



Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).




    public boolean isSymmetric(TreeNode root) {
if (root == null) {
return true;
}

Deque<TreeNode> leftQ = new LinkedList<>();
Deque<TreeNode> rightQ = new LinkedList<>();

leftQ.offer(root.left);
rightQ.offer(root.right);

while (!leftQ.isEmpty() && !rightQ.isEmpty()) {
TreeNode left = leftQ.poll();
TreeNode right = rightQ.poll();

if (left == null && right == null) {
continue;
}
if (left == null || right == null) {
return false;
}
if (left.val != right.val) {
return false;
}

leftQ.offerLast(left.left);
leftQ.offerLast(left.right);
rightQ.offerLast(right.right);
rightQ.offerLast(right.left);

}


return leftQ.isEmpty() && rightQ.isEmpty();
}


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten LeetCode Day 12

Thematisch verwandte Begriffe: LeetCode · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94030 | A security vulnerability has been detected in SerenityOS up to 3d83e4509…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick