Dev Prakash Sharma has Published 548 Articles

Write a program in C++ to remove duplicates from a given array of prime numbers

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:46:48

346 Views

Let us suppose we have given an array N size which consists of all the prime numbers. The task is to find the duplicates in the given array and remove them. For example, Input-1 −N = 8 arr[ ] = { 2 ,2 ,2 ,3 ,3 ,3 ,5 ,7 }Output ... Read More

Remove comments in a string using C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:46:09

1K+ Views

Given a C++ program as input, remove the comments from it. ‘source’ is a vector where the i-th line of the source code is the source[i]. This represents the result of splitting the source code string by the newline character . In C++, we can create two types of comments, ... Read More

Nth Catalan Number in Go Lang

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:45:36

234 Views

Catalan Numbers are sequences of natural numbers that gives the number of BST (Binary Search Tree) possible with n Values. So, the Catalan number is a full binary tree with n+1 leaves.Some applications of Catalan Numbers are counting the pairs of nested parentheses, valid mountain ranges etc.For n = 5, ... Read More

Majority Element in Java

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:43:28

1K+ Views

Let’s suppose we have given an array of integers. The task is to find the index of a particular element in the given array. For example, Input-1 −N = 8 A[ ] = { 1, 2, 4, 3, 3, 1, 1, 5}Output −1Explanation − In the given array of integers, ... Read More

Write a program in C++ to insert a Node at the beginning of the given Singly linked list

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:43:04

7K+ Views

A linked List is a linear data structure that has multiple nodes that are connected with each other. Each node consists of two fields Data Field and address of the next node.Let us assume we have given a singly linked list the task is to insert a node at the ... Read More

Insertion in the Red Black Tree in Data Structure

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:42:32

8K+ Views

Red Black Tree is a Self-Balanced Binary Search Tree in which each node of the tree is colored with either Red or Black. There are three types of operations we can perform on a Red Black Tree – Searching, Insertion and Deletion.Let us suppose we have to insert an element ... Read More

What are pandigital numbers. Approach to find the pandigital Numbers using C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:36:00

495 Views

Pandigital Number − In Mathematics, a Pandigital number is an integer that in a given base has among its significant digits each digit used in the base at least once.Pandigital numbers are the integers in which each digit is used as the base at least one time.For example, 1245678 is ... Read More

Check if two strings are anagram of each other using C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:35:32

2K+ Views

Let’s Suppose we have given two strings ‘a’ and ‘b. We have to check that the given two strings are anagram of each other or not. Two Strings are said to be anagram of each other if one string contains the same character as another.For ExampleInput-1 −a= anagram b= gnaramaOutput ... Read More

Given a sorted array of 0’s and 1’s, find the transition point of the array in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:34:33

684 Views

Given an array of sorted numbers containing only 0s and 1s, find the transition point. A transition point is the index of the first ‘1’ appearing in the array. For example, Input-1 −N = 6 arr[ ] = {0, 0, 0, 0, 1, 1}Output −4Explanation − Since in the given ... Read More

Floyd Cycle Detection Algorithm to detect the cycle in a linear Data Structure

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:22:42

617 Views

Floyd Cycle is one of the cycle detection algorithms to detect the cycle in a given singly linked list.In the Floyd Cycle algorithm, we have two pointers that initially point at the head. In Hare and Tortoise’s story, Hare moves twice as fast as Tortoise, and whenever the hare reaches ... Read More

Advertisements