Dev Prakash Sharma has Published 548 Articles

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

1K+ 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

4K+ 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

550 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

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

472 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

Find the index of the first unique character in a given string using C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:07:52

2K+ Views

Given a string ‘s’, the task is to find the first unique character which is not repeating in the given string of characters and return its index as output. If there are no such characters present in the given string, we will return ‘-1’ as output. For example, Input-1 −s ... Read More

Detect Capital in a given string using C++

Dev Prakash Sharma

Dev Prakash Sharma

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

575 Views

Let's suppose we have a string ‘str’ which consists of some character in it. The task is to check whether the given string has all its characters capitalized or not and return True or False respectively. For example, Input-1 −str = “INDIA”Output −TrueExplanation − Since all the character of the ... Read More

Delete a tail node from the given singly Linked List using C++

Dev Prakash Sharma

Dev Prakash Sharma

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

2K+ Views

A Linked List is a linear Data Structure that contains nodes and each node has two fields; one is the value or data to be inserted and the other field stores the address of the next node.Our task here is to delete a node from the end of a Linked ... Read More

Write a program in Python to count the number of digits in a given number N

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 11:58:55

8K+ Views

Let's suppose we have given a number N. the task is to find the total number of digits present in the number. For example, Input-1 −N = 891452Output −6Explanation − Since the given number 891452 contains 6 digits, we will return ‘6’ in this case.Input-2 −N = 0074515Output −5Explanation − Since ... Read More

Count Good Meals in Python

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 11:58:15

332 Views

A good meal contains exactly two different food items with a sum of deliciousness equal to a power of two. You can pick any two different foods to make a good meal.Let us suppose we have given an array of integers arr where arr[i] is the deliciousness of the ith ... Read More

Write a program in JavaScript to check if two strings are anagrams of each other or not

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 11:57:40

22K+ Views

Given two strings ‘a’ and string ‘b’, we have to check if they are anagrams of each other or not and return True/False. For example, Input-1 −String a= “india” String b= “nidia”Output −TrueExplanation − Since the given string ‘b’ contains all the characters in the string ‘a’ thus we will ... Read More

Advertisements