Hafeezul Kareem has Published 344 Articles

Find a peak element in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 01-Feb-2021 12:03:51

227 Views

In this tutorial, we are going to write a program that finds the peak element in the given arrayThe peak element is an element that is greater than the surrounding elements. Let's see the steps to solve the problem.Initialize the array with dummy data.Check for the first element and last ... Read More

Find a peak element in Linked List in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 01-Feb-2021 12:01:44

252 Views

In this tutorial, we are going to write a program that finds the peak element in the given linked list.The peak element is an element that is greater than the surrounding elements. Let's see the steps to solve the problem.Create a struct node for the linked list.Create the linked list ... Read More

Find a peak element in a 2D array in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 01-Feb-2021 12:00:32

283 Views

In this tutorial, we are going to write a program that finds the peak element in a 2D array.An element is called a peak element if all the elements around it are smaller than the element.Let's see the steps to solve the problem.Initialize the 2D array with dummy data.Iterate over ... Read More

Find a partition point in array in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 01-Feb-2021 11:59:38

350 Views

In this tutorial, we are going to find the partition point in an array where all the elements left to the partition point are small and all the elements right to the partition point are large.Let's see the steps to solve the problem.Initialize the array.Iterate over the array.Iterate from 0 ... Read More

Find a pair with given sum in BST in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 01-Feb-2021 11:58:31

135 Views

In this tutorial, we are going to write a program that finds the pair whose sum is equal to the given number in the binary search tree.We are going to store and values of trees in two different lists to find the pairs. Let's see the steps to solve the ... Read More

Find a Number X whose sum with its digits is equal to N in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 01-Feb-2021 11:58:04

141 Views

In this tutorial, we are going to find a number whose some including with its digits is equal to the given number N.The idea is simple, we are going to check the left and right 100 numbers of the given number. It won't lie out that bound as N ≤ ... Read More

Find a number that divides maximum array elements in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 01-Feb-2021 11:57:48

123 Views

In this tutorial, we are going to find the number that is divided into maximum elements in the given array.Let's see the steps to solve the problem.Initialize the array and a variable to store the result.Iterate over the array.Initialize the counter variable.Iterate over the array again.Increment the counter if the ... Read More

Find a Fixed Point (Value equal to index) in a given array in C++ Program

Hafeezul Kareem

Hafeezul Kareem

Updated on 01-Feb-2021 11:48:14

198 Views

In this tutorial, we are going to solve the following problem.Given an array, find the number which is equal to the index. It's a straightforward problem.Iterate over the given array and return the index which is equal to the array element.ExampleLet's see the code. Live Demo#include using namespace std; int ... Read More

Find (1^n + 2^n + 3^n + 4^n) mod 5 in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 01-Feb-2021 11:47:43

208 Views

In this tutorial, we are going to solve the following problem.Given an integer n, we have to find the (1n+2n+3n+4n)%5The number (1n+2n+3n+4n) will be very large if n is large. It can't be fit in the long integers as well. So, we need to find an alternate solution.If you solve ... Read More

Find 2^(2^A) % B in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 01-Feb-2021 11:45:39

76 Views

In this tutorial, we are going to write a program to evaluate the equation 2^(2^A) % B.We are going to find the value of the equation using a recursive function. Let's see the steps to solve the problem.Write a recursive function that takes 2 arguments A and B.If A is ... Read More

Advertisements