Problem Statement: You are given an array, you need to check if a number and its double exist in that array. Example Input arr = {10, 2, 5, 3} Output: True N = 5 M = 10. 5*2 = 10. So there exist 2 integers, such …
Question: Given an unsorted array with distinct elements, you are also given an integer “k”. You need to find the k’th smallest/largest element in the array. Example: Input : {5, 6, 7, 8, 9, 10} k = 2 k'th smallest element = 6 k'th largest …
Problem Statement: You are given an integer n. You need to return the integers that sum upto 0. Example Input: n = 5 Output: {-5, -1, 1, 2, 3} Solution Method 1: In this method, we will use the numbers from 1, 2, .. n-1 and …
Problem Statement: You are given an array of integers. You need to return the count of the numbers that has even number of digits. Example Input arr = {12, 123, 1234, 12345, 123456} Output: 3 The numbers {12, 1234, 123456} has even digits. Solution …
Question: Given a 2 binary trees root nodes, check if the structure is mirror to each other. Example: Consider the image given below and its mirror. If you can see in the above image, both the trees structure are mirror to each other. We don’t consider …
Consider the below image You need to print the leaf node: Form left to right: 7, 15, 18, 30 Form right to left : 30, 18, 15, 7 Solution in C++ #include <iostream> #include <queue> #include <stack> using namespace std; // structure to hold binary tree …
Question: Given a binary tree root node, get the deepest left leaf node Example: Consider the image given below and its mirror. From the above image, node 7 is the deepest left leaf node. Solution in C++ #include <iostream> #include <queue> #include <stack> using namespace std; …