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 […]
Converter Pattern using Spring Dependency Injection
1. Introduction In this article, I will talk about the converter pattern using Spring’s Dependency Injection. We constantly find ourselves writing request or response mapping […]
Collectors partitioningBy and counting to Count and add Even Odd Numbers.
1. Introduction In this article, I will discuss how we can use Java 8 methods to count and add even odd numbers of an array. […]
Random class Java 8 Methods(ints(), longs(), doubles()) with 12 examples.
1. Overview In this article, I will go through the new methods added in Random class under java.util package. Random class provides several methods that […]
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 […]