Dev Prakash Sharma has Published 556 Articles

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

478 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

453 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

Write a program in C++ to find the top K frequent element in an array of integers

Dev Prakash Sharma

Dev Prakash Sharma

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

729 Views

Suppose we have an array of integers of size N and a key K. Our task is to print the top K most frequent element of the array. For example, Input-1 −N = 6 K = 2 arr[ ] = {1 ,1, 1, 2, 2, 3}Output −1 2Explanation − In ... Read More

Write a program in C++ to find the most frequent element in a given array of integers

Dev Prakash Sharma

Dev Prakash Sharma

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

3K+ Views

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

Write a program in Java to find the missing positive number in a given array of unsorted integers

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:15:59

410 Views

Let’s suppose we have given an array of unsorted integers. The task is to find the positive missing number which is not present in the given array in the range [0 to n]. For example, Input-1 −N = 9 arr = [0, 2, 5, 9, 1, 7, 4, 3, 6]Output ... Read More

Write a program in C++ to find the missing positive number in a given array of unsorted integers

Dev Prakash Sharma

Dev Prakash Sharma

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

332 Views

Let’s suppose we have given an array of unsorted integers. The task is to find the positive missing number which is not present in the given array in the range [0 to n]. For example, Input-1 −N = 9 arr = [0, 2, 5, 9, 1, 7, 4, 3, 6]Output ... Read More

Write a program in C++ to find the maximum and second maximum in a given unsorted array of integers

Dev Prakash Sharma

Dev Prakash Sharma

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

4K+ Views

Let’s suppose we have given an array of unsorted integers of size N. The task is to find the distinct max and second max element which are present in the array. The array may contain duplicate elements also. So we have to find only distinct elements. For example, Input-1 −N ... Read More

Write a program in C++ to find the length of the largest subarray with zero sum

Dev Prakash Sharma

Dev Prakash Sharma

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

207 Views

Suppose we have given an array of N integers having the task is to find the length of the subarray having a maximum length. If there is not any subarray whose length is maximum or sum is equal to 0 then return ‘0’. For example, Input-1 −N = 8 A[ ... Read More

Find the Kth Node from the end in a given singly Linked List using C++

Dev Prakash Sharma

Dev Prakash Sharma

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

359 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 find the kth node ... Read More

Advertisements