Sudhir sharma has Published 1149 Articles

Form the largest number using at most one swap operation C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 09:15:48

261 Views

In this problem, we are given a positive integer. Our task is to create a program to form the largest number using at most one swap operation.We will be creating a new number using the digits of the existing number.The largest number formed can have only one digit swapped from ... Read More

Flood fill Algorithm – how to implement fill() in paint in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 09:03:01

841 Views

In this problem, we are given a 2d array representing a 2-D screen, the coordinates of a pixel on the screen to be filled with color and the color. Our task is to create a program to Color the current pixel and all the adjacent pixels which have that color.Coloring ... Read More

For every set bit of a number toggle bits of other in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:50:43

296 Views

In this problem, we are given two integer values. Our task is to create a c program to operform the operation, For every set bit of a number toggle bits of other. Let’s take an example to understand the problemInput: 3 7 Output: 4 Binary of 3: 011 Binary of 3: ... Read More

Find XOR of two number without using XOR operator in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:44:57

946 Views

In this problem, we are given integer values A & B. Our task is to find XOR of two numbers without using the XOR operator.Let's take an example to understand the problem, Input : A = 4, B = 5 Output : 1Solution ApproachOne method to solve the problem is ... Read More

Find x, y, z that satisfy 2/n = 1/x + 1/y + 1/z in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:40:01

161 Views

In this problem, we are given integer values n. Our task is to find x, y, z that satisfy 2/nx + 1/y + 1/z.Let's take an example to understand the problem, Input : n = 4 Output : 4, 5, 20Solution ApproachA simple solution to the problem is by finding ... Read More

Find x and y satisfying ax + by = n in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:36:35

610 Views

In this problem, we are given three integer values a, b, and n. Our task is to find x and y satisfying ax + by = n.Let's take an example to understand the problemInput : a = 4, b = 1, n = 5 Output : x = 1, y ... Read More

fopen() for existing file in write mode in C

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:35:23

1K+ Views

fopen() method in C is used to open the specified file.Let’s take an example to understand the problemSyntaxFILE *fopen(filename, mode)The following are valid modes of opening a file using fopen(): ‘r’, ‘w’, ‘a’, ‘r+’, ‘w+’, ‘a+’. For details visit visit C library function - fopen()fopen() for an existing file in ... Read More

Find whether an array is subset of another array - Added Method 3 in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:28:58

468 Views

In this problem, we are given two arrays of integers arr1[] and arr2[] of size m and n. Our task is to find whether an array is subset of another array - Added Method 3.Both arrays arr1[] and arr2[] are unorders and have distinct elements.Let's take an example to understand ... Read More

Find whether a subarray is in form of a mountain or not in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:13:26

210 Views

In this problem, we are given an array of integers arr[] and an range. Our task is to find whether a subarray is in the form of a mountain or not.Let's take an example to understand the problem, Input : arr[] = {1, 4, 2, 5, 6, 7, 3, 0}, ... Read More

Game of Nim with removal of one stone allowed in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:10:55

240 Views

In this problem called the game of Nim, we are given a positive integer N denoting the pile of stones and there are two players ‘playerA’ and ‘playerB’. Our task is to create a program to predict the winner of the Game of Nim.GAME OF NIM − We have a ... Read More

Advertisements