Hafeezul Kareem has Published 344 Articles

K’th Smallest/Largest Element using STL in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 12:58:23

647 Views

In this tutorial, we are going to write a program that finds the k-th smallest number in the unsorted array.Let's see the steps to solve the problem.Initialise the array and k.Initialise a empty ordered set.Iterate over the array and insert each element to the array.Iterate over the set from 0 ... Read More

K’th Smallest/Largest Element in Unsorted Array in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 12:37:28

147 Views

In this tutorial, we are going to write a program that finds the k-th smallest number in the unsorted array.Let's see the steps to solve the problem.Initialise the array and k.Sort the array using sort method.Return the value from the array with the index k - 1.ExampleLet's see the code. Live ... Read More

K’th Least Element in a Min-Heap in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 12:37:03

437 Views

In this tutorial, we are going to write a program that finds the k-th least element from the min-heap.We will use priority queue to solve the problem. Let's see the steps to complete the program.Initialise the min-heap with correct values.Create a priority queue and insert the root node of the ... Read More

K’th Boom Number in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 12:36:39

169 Views

In this tutorial, we are going to write a program that finds the k-th boom number.The number that contains only 2 and 3 are called boom number.Let's see the steps to solve the above problem.Initialise the value of k.Initialise a queue of strings.Push the empty string to the queue.Initialise a ... Read More

K-th smallest element after removing some integers from natural numbers in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 12:36:15

178 Views

In this tutorial, we are going to write a program that finds out the smallest element after removing some integers from the natural numbers.We have given an array of elements and k value. Remove all the elements from natural numbers that are present in the given array. And then find ... Read More

k-th missing element in sorted array in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 12:35:55

225 Views

In this tutorial, we are going to write a program that finds out the k-th missing element in the given sorted array.Find the k-th number that is missing from min to max in the given unsorted array. Let's see the steps to solve the problem.Initialise the sorted array.Initialise two variables ... Read More

k-th missing element in an unsorted array in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 12:35:02

133 Views

In this tutorial, we are going to write a program that finds out the k-th missing element in the given unsorted array.Find the k-th number that is missing from min to max in the given unsorted array. Let's see the steps to solve the problem.Initialise the unsorted array.Insert all the ... Read More

K-th Greatest Element in a Max-Heap in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 12:34:24

1K+ Views

In this tutorial, we are going to write a program that finds the k-th largest element from the max-heap.We will use priority queue to solve the problem. Let's see the steps to complete the program.Initialise the max-heap with correct values.Create a priority queue and insert the root node of the ... Read More

K-th Element of Two Sorted Arrays in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 12:28:57

102 Views

In this tutorial, we are going to write a program that finds the k-th element from thee merged array of two sorted arrays.Let's see the steps to solve the problem.Initialise the two sorted arrays.Initialise an empty array of size m + n.Merge the two arrays into the new array.Return the ... Read More

K-th digit in ‘a’ raised to power ‘b’ in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 12:27:43

246 Views

In this tutorial, we are going to write a program that finds the k-th digit from the right side in the number abIt's a straightforward problem. Let's see the steps to solve it.Initialise the numbers a, b, and k.Find the value of abusing pow method.Write a loop that iterates until ... Read More

Advertisements