Dev Prakash Sharma has Published 556 Articles

Find the Number of 1 Bits in a large Binary Number in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 19:34:20

2K+ Views

Given a 32-bit Unsigned Binary Number, the task is to count the set bits, i.e., '1's present in it.For ExampleInput:N = 00000000000000100111Output:4Explanation: Total set bits present in the given unsigned number is 4, thus we will return the output as '4'.Approach to Solve this ProblemWe have given an unsigned 32-bit binary ... Read More

C++ Program to find the Shortest Distance to a character

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 19:32:58

416 Views

Given a string 'a' and a character 'char', the task is to print the distance of 'char' from each character of the given string. The size of the distance array is same as the size of the string, since we have to find the distance of the character from each ... Read More

Find the sum of left leaf nodes of a given Binary Tree in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 19:29:51

909 Views

Let us suppose we have a Binary Tree having a root node and its left child and right child. The task is to find the total sum of leaf nodes of the tree which are left to its parent node.For ExampleInput-1:      Output:15Explanation: In the given input Binary Tree, the sum ... Read More

Intersection of Two Linked Lists in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 19:28:35

1K+ Views

A Linked List is a linear data structure in which each node has two blocks such that one block contains the value or data of the node and the other block contains the address of the next field.Let us assume that we have a linked list such that each node ... Read More

Largest Merge of Two Strings in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 19:26:42

172 Views

Let us suppose we have two strings 'a' and 'b' and a string 'merge'. The task is to fill the string 'merge' with the characters from 'a' and 'b' in such a way that, If the string 'a' is non-empty, then remove the first character from the string 'a' and ... Read More

Make three numbers Zero in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 19:22:11

168 Views

Let us suppose we have three numbers. The task is to count the total number of optimal steps to make all these numbers '0'.For ExampleInput-1:a = 4 b = 4c = 6Output:7Explanation: Total number of optimal steps to make all the numbers '0' is, (4, 4, 6)Removing '1' from 1st and ... Read More

Powerful Integers in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 19:19:43

185 Views

Let us suppose we have three integers 'a' and 'b' and 'limit'. The task is to print the numbers in the range [a, limit]. List of these numbers is said to be powerful integers and represented as, a^i + b^j such that i >= 0 and j >= 0For ExampleInput-1:a ... Read More

Write a program in C++ to split two strings to make it a palindrome

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 19:14:29

220 Views

A string is said to be a palindromic string if it remains the same after reversing it.In this particular problem, we've given two strings 'a' and 'b' of the same length. If they are split with some indexes, then the task is to check whether the sum of the strings ... Read More

Symmetric Tree in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 19:10:18

492 Views

Let us suppose we have a binary tree and the task is to check whether it constructs a symmetry of itself or not. A Symmetric Binary tree constructs the mirror image of itself.For ExampleInput-1:           Output:TrueExplanation:Since the given binary tree constructs the mirror image of itself, the output ... Read More

Balanced Binary Tree in Python

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 23-Feb-2021 19:08:10

4K+ Views

In a binary tree, each node contains two children, i.e left child and right child. Let us suppose we have a binary tree and we need to check if the tree is balanced or not. A Binary tree is said to be balanced if the difference of height of left ... Read More

Advertisements