Hafeezul Kareem has Published 328 Articles

Largest subarray having sum greater than k in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 14:00:21

369 Views

In this tutorial, we are going to write a program that finds the largest subarray have sum greater than k.Let's see the steps to solve the problem.Initialise the array.Iterate over the array and store sum at each index in a vector along with the index.Sort the above sums based on ... Read More

Largest smaller number possible using only one swap operation in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:58:06

177 Views

In this tutorial, we are going to write a program that finds the largest number with a single swap that is less than the given number n.Let's see the steps to solve the problem.Initialise the number n.Iterate from the end of the string and find the index of the digit ... Read More

Largest set with bitwise OR equal to n in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:55:39

104 Views

In this tutorial, we are going to write a program that finds the largest set with bitwise OR is equal to the given number n.Let's see the steps to solve the problem.Initialise the number n.Write a loop that iterates from 0 to n.If the i | n is equal to ... Read More

Largest permutation after at most k swaps in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:55:19

637 Views

In this tutorial, we are going to write a program that finds the largest permutation after at most k swaps.Let's see the steps to solve the problem.Initialise the array.Initialise an array to store the index with size n + 1.Iterate over the array and store the index of each element ... Read More

Largest number with the given set of N digits that is divisible by 2, 3 and 5 in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:48:33

221 Views

In this tutorial, we are going to write a program that finds the largest number formed from the array that is divisible by 2, 3, and 5.Let's see the steps to solve the problem.Initialise the array.The number must end with 0 and the sum of all the numbers should be ... Read More

Largest number with prime digits in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:44:56

398 Views

In this tutorial, we are going to write a program that finds the largest number with prime digits that is less than n.Let's see the steps to solve the problem.Write a loop that iterates from 0 to n.If the current digit is not prime.While the digit is less 2, decrement ... Read More

Largest number with one swap allowed in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:42:25

472 Views

In this tutorial, we are going to write a program that finds the largest number with a single swap.Let's see the steps to solve the problem.Initialise the number n.Convert the integer to string.Write a loop that iterates from the ending of the string.Find the max digit and index.If the current ... Read More

Largest number with binary representation is m 1’s and m-1 0’s in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:40:36

194 Views

In this tutorial, we are going to write a program that finds the largest number with m 1's and m - 1 0's.Let's see the steps to solve the problem.Initialise two variables bits and result with 2 and 1 respectively.Write a loop that iterates from 1 to n.Update the iterating ... Read More

Largest number smaller than or equal to N divisible by K in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:40:18

189 Views

In this tutorial, we are going to write a program that finds the number that is smaller than or equal to N and divisible by k.Let's see the steps to solve the problem.Initialise the numbers n and k.Find the remainder with modulo operator.If the remainder is zero, then return n.Else ... Read More

Largest number less than X having at most K set bits in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:34:07

108 Views

In this tutorial, we are going to write a program that finds the largest number which is less than given x and should have at most k set bits.Let's see the steps to solve the problem.Initialise the numbers x and k.Find the set bits in the number x.Write a loop ... Read More

Previous 1 ... 7 8 9 10 11 ... 33 Next
Advertisements