Hafeezul Kareem has Published 345 Articles

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

127 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

53 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

Largest number less than N with digit sum greater than the digit sum of N in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:32:49

252 Views

In this tutorial, we are going to write a program that finds the number less than N with digit sum greater than the digit sum of n.Let's see the steps to solve the problem.Write a function to find the digits sum.Initialise n.Write a loop that iterates from n - 1 ... Read More

Largest N digit number divisible by given three numbers in C++

Hafeezul Kareem

Hafeezul Kareem

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

201 Views

In this tutorial, we are going to write a program that finds the largest n-digit number that is divisible by the given three numbers.Let's see the steps to solve the problem.Initialise three numbers along with n.Find the LCM of three numbers.Store the largest number with n-digits.If the largest number is ... Read More

Largest K digit number divisible by X in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:29:35

99 Views

In this tutorial, we are going to write a program that finds the largest k-digit number that is divisible by x.Let's see the steps to solve the problem.Initialise the x and k.Find the value of pow(10, k) - 1 which is largest k-digit number.Now, remove the remainder value from the ... Read More

Largest gap in an array in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:26:16

197 Views

In this tutorial, we are going to write a program that finds the largest difference between the two elements in the given array.Let's see the steps to solve the problem.Initialise the array.Find the max and min elements in the array.Return max - min.ExampleLet's see the code. Live Demo#include using namespace ... Read More

Largest even number possible by using one swap operation in given number in C++

Hafeezul Kareem

Hafeezul Kareem

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

629 Views

In this tutorial, we are going to write a program that finds the largest possible even number with a single swap of digits.Let's see the steps to solve the problem.Initialise the number in string format.Iterate over the given number.Find the even digit that is less than or equal to the ... Read More

Largest even digit number not greater than N in C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 09-Apr-2021 13:20:05

113 Views

In this tutorial, we are going to write a program that finds the largest number whose digits are all even and not greater than the given n.Let's see the steps to solve the problem.Initialise the number n.Write a loop from i = n .Check whether the digits of current number ... Read More

Largest Even and Odd N-digit numbers in C++

Hafeezul Kareem

Hafeezul Kareem

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

295 Views

In this tutorial, we are going to write a program that finds the largest even and odd number of n digits number.Let's see the steps to solve the problem.Initialise the number n.The largest odd number is pow(10, n) - 1.The largest even number is odd - 1.ExampleLet's see the code. Live ... Read More

Larger of a^b or b^a in C++

Hafeezul Kareem

Hafeezul Kareem

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

215 Views

In this tutorial, we are going to write a program that finds out the larger among the ab and baIt's a straightforward problem. Let's see the steps to solve it.Initialise the values of a and b.Take the log of both the values.Compute the values of $b\:\log\:a$ and $a\:\log\:b$Compare the both ... Read More

Advertisements