Hafeezul Kareem has Published 345 Articles

Largest subarray with equal number of 0s and 1s in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 14:14:28

117 Views

Let's see the steps to complete the program.Initialise the array.Make all zeroes in the array to -1.Have a map an empty map to store the previous indexes.Initialise sum to 0, max length to 0 and ending index to -1.Write a loop that iterates till n.Add current element to sum.If the ... Read More

Largest sum subarray with at-least k numbers in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 14:06:53

271 Views

Let's see the steps to complete the program.Initialise the array.Initialise max_sum array of size n.Find the max sum for every index and store it in max_sum array.Compute the sum of all the elements and store it in a variable sum.Write a loop that iterates from i = k to n.Add ... Read More

Largest subarray having sum greater than k in C++

Hafeezul Kareem

Hafeezul Kareem

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

260 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

107 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

58 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

455 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

155 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

327 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

359 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

132 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

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