Shubham Vora has Published 957 Articles

Count permutations possible by replacing ‘?’ characters in a Binary String

Shubham Vora

Shubham Vora

Updated on 10-Aug-2023 10:24:47

184 Views

In this problem, we have given a string containing 0, 1, and ? characters. We need to find permutations of the string by replacing ‘?’ with 0 and 1. The logic to solve the problem is that we can replace every ‘?’ with either 0 or 1. So, by replacing ... Read More

Count new pairs of strings that can be obtained by swapping first characters of pairs of strings from given array

Shubham Vora

Shubham Vora

Updated on 10-Aug-2023 10:22:24

155 Views

In this problem, we need to select the pair of strings and swap their first character. After that, we need to count the total number of new pairs. We can solve the problem by swapping the first character of each pair and checking whether it exists in the array. The ... Read More

Check if the number formed by concatenating all array elements is a Harshad number or not

Shubham Vora

Shubham Vora

Updated on 10-Aug-2023 10:19:29

140 Views

In this problem, we have given the array of integers. We need to combine all elements in a single integer and check if it is a Harshad number. Before we move with the solution, let’s understand Harshad number. All numbers are Harshad numbers which are divisible by the sum of ... Read More

Check if all characters of a string can be made equal by increments or decrements

Shubham Vora

Shubham Vora

Updated on 10-Aug-2023 10:17:50

224 Views

In this problem, we need to check if we can make all characters of strings equal by increment and decrement operations. We can get the weight of each character based on their ASCII values and check whether the total weight can be used to make all characters equal. Problem statement ... Read More

Size of all Connected Non-Empty Cells of a Matrix

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 15:59:44

153 Views

In this problem, we will find the size of sets of all non−empty connected cells. We will learn two different approaches for finding the size of all non−empty connected cells of a matrix. In the first approach, we will use the breadth−first search algorithm, and in the second approach, we ... Read More

Restore a Shuffled Queue as Per given Conditions

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:55:29

138 Views

In this problem, we have given the persona names and the number of taller people standing in front of that people. We can sort the position of the people according to the number of taller people standing in front of any person. After that, we update the position of each ... Read More

Minimum Nodes to be Colored in a Graph such that every Node has a Colored Neighbour

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:53:47

161 Views

In this problem, we will color the minimum nodes of the graph such that each node of the graph has a colored node at the maximum distance 1. The simple logic to minimize the count of the colored node is that either color the nodes which are at an odd ... Read More

Minimum Distance from a given Cell to all other Cells of a Matrix

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:51:23

256 Views

In this problem, we need to find the distance of each cell from the given cell of the matrix. We will use the Breadth−first search traversal to visit each cell of the matrix from the given cell and find the minimum distance for each cell. Problem statement − We ... Read More

Minimum Cost using Dijkstra by Modifying Cost of an Edge

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:49:54

354 Views

In this problem, we need to find the minimum path from 1 to N using Dijakstra’s algorithm, and we can update the cost of any single edge to cost/2. Here, we will find each node's distance from the source node to the destination node. After that, we will take the ... Read More

Maximum Possible Array Sum after Performing given Operations

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:47:10

595 Views

In this problem, we will perform the given operations on the array elements and find the maximum sum at last. Here, in each operation, we can select at most X[p] elements from the array and replace them with the Y[p] elements to maximize the sum. In the naïve approach, ... Read More

Advertisements