easy-problems

First Bad Version | Leetcode | Solution

Hi, In this post we will be discussing the first bad version problem present on LeetCode Video Solution Problem Statement You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous …

First Bad Version | Leetcode | Solution Read More »

Count Good Nodes In Binary Tree | LeetCode

Problem Source Given a binary tree containing N nodes, where each node contains some value. Count the number of good nodes in the tree. Count Good Nodes In Binary Tree Video Explanation Count Good Nodes In Binary Tree Solution For example, in the below tree The nodes marked in blue are good nodes, because they …

Count Good Nodes In Binary Tree | LeetCode Read More »

Deepest Leaves Sum | LeetCode

Problem Source Given a binary tree with N nodes. Each node in the binary tree contains some value associated with it. Find the sum of values present in the leaf nodes present at highest depth. For example for the tree given below, the sum is 7 + 8 = 15. Because and 7 and 8 …

Deepest Leaves Sum | LeetCode Read More »

How to check if two binary trees are identical ?

Given two binary trees, write a program to check if the two binary trees are identical or not ? Solution We can solve the above problem recursively. If the root node of the tree is equal then we check for the equality of left subtree and right subtree.Similarly, we check for the equality of the …

How to check if two binary trees are identical ? Read More »

Find Missing Number In An Array Without Using Extra Space

Given an array of size n-1 which contains all the numbers within range 1 to n with exactly one number as missing. Find that missing number without using any extra space. Test Cases Test Case 1 Input: 1 2 4Output: 3Explanation: 3 is missing in the above array. Test Case 2 Input: 1 3 4 …

Find Missing Number In An Array Without Using Extra Space Read More »

Sort an array in one swap where two elements are swapped by mistake

Given an array of size n in which two elements were swapped by mistake. Sort this array in one swap. It is guaranteed that such a solution exists. This array doesn’t contain duplicates Test Cases Example Input 1 Input Array: 1 2 3 6 5 4Expected Output: 1 2 3 4 5 6In the above …

Sort an array in one swap where two elements are swapped by mistake Read More »

Logger Rate Limiter | Leet Code

Logger Rate Limiter | Leet Code Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in the last 10 seconds. Given a message and a timestamp (in seconds granularity), return true if the message should be printed in …

Logger Rate Limiter | Leet Code Read More »

Bulls & Cows | Leet Code

Bulls And Cows | Leet Code You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your secret …

Bulls & Cows | Leet Code Read More »

Scroll to Top
[gravityforms id="5" description="false" titla="false" ajax="true"]