1. Introduction Given the root of a binary tree, flatten the tree into a “linked list”: The “linked list” should use the same TreeNode class […]
Leetcode 922. Sort Array By Parity II.
1. Introduction Given an array of integers nums, half of the integers in nums are odd, and the other half are even. Sort the array […]
Leetcode 590. N-ary Tree Postorder Traversal using Recursion and Iteration.
1. Introduction Given the root of an n-ary tree, return the postorder traversal of its nodes’ values. This article is part of Binary Tree-Traversals. Read […]
Leetcode 589. N-ary Tree Preorder Traversal using Recursion and Iteration.
1. Introduction Given the root of an n-ary tree, return the preorder traversal of its nodes’ values. This article is part of Binary Tree-Traversals. Read […]
Leetcode 429. N-ary Tree Level Order Traversal.
1. Introduction Given an n-ary tree, return the level order traversal of its nodes’ values (i.e., from left to right, level by level). You can […]
Binary Tree Postorder Iterator.
Given the root of a Binary Tree, implement a Postorder Iterator with methods hasNext() and next(). 1. Introduction In this article, I will discuss how […]
Leetcode 144. Binary Tree Postorder Traversal.
Leetcode 144. Binary Tree Postorder Traversal: Given the root of a binary tree, return the Postorder traversal of its nodes’ values. This article is part […]
Leetcode 101. Symmetric Tree. Check whether tree is a mirror of itself.
1. Introduction Given the root of a binary tree, check whether it is a mirror of itself (symmetric around its center). 2. Content If the […]
Leetcode 100. Same Tree or Identical binary trees.
1. Introduction Given the roots of two binary trees p and q, write a function to check if they are the same or not. We […]
Leetcode 102. Binary Tree Level Order Traversal.
1. Introduction Given the root of a binary tree, return the binary tree level order traversal of its nodes’ values. (i.e., from left to right, […]
Leetcode 965. Univalued Binary Tree.
1. Introduction A binary tree is uni-valued if every node in the tree has the same value. Given the root of a binary tree, return […]
Binary Tree Preorder Iterator.
Given the root of a Binary Tree, implement a Preorder Iterator with methods hasNext() and next(). 1. Introduction In this article, I will discuss how […]
Leetcode 144. Binary Tree Preorder Traversal (Recursive and Iterative)
Given the root of a binary tree, return the Preorder traversal of its nodes’ values. 1. Introduction In this article, I will discuss how to […]
Leetcode 173. Binary Search Tree Iterator.
Given the root of a Binary Search Tree, implement an Inorder Iterator with methods hasNext() and next(). 1. Introduction In this article, I will discuss […]
Leetcode 94. Binary Tree Inorder Traversal (Recursive and Iterative)
Given the root of a binary tree, return the Inorder traversal of its nodes’ values. 1. Introduction In this article, I will discuss how to […]
Leetcode 242. Valid Anagram
Leetcode 242. Valid Anagram: An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all […]
LeetCode 905. 4 different ways to Sort Array By Parity – Moving Even Numbers to Left and Odd Numbers to Right.
LeetCode 905: Given an array nums of non-negative integers, return an array comprising all the even elements of nums, followed by all the odd elements […]
Count occurrences of substring in input string
1. Introduction In this article we will count occurrences of substring in input string. Below is an exmaple. 2. So, how to write a code […]
Count frequency of all characters in String
1. Introduction In this String relation interview question, we are supposed to find the frequency of every character in String. For example: Input Output “” […]
Check if two strings are anagram
1. Introduction Two strings are anagram of each other if all the characters of one string matches another string’s characters. 2. Different ways to check […]