Arnab Chakraborty has Published 4293 Articles

Program to rotate a linked list by k places in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 10:34:18

365 Views

Suppose we have a linked list. We have to rotate the list to the right by k places. The value of k will be positive. So if the list is like [1 −> 2 −> 3 −> 4 −> 5 −> NULL], and k = 2, then the output will ... Read More

Program to rotate square matrix by 90 degrees counterclockwise in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 10:32:49

2K+ Views

Suppose we have a square matrix, we have to rotate it 90 degrees counter-clockwise.147258369then the output will be789456123To solve this, we will follow these steps −if matrix is empty, thenreturn a blank listn := row count of matrixfor each row in matrix, doreverse the rowfor i in range 0 to ... Read More

Program to check robot can reach target by keep moving on visited spots in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 10:28:38

260 Views

Suppose we have a robot, that is currently sitting in at position (0, 0) (Cartesian plane). If we have list of its moves that it can make, containing N(North), S(South), W(West), and E(East). However, if the robot reaches a spot it has been in before, it will continue moving in ... Read More

Program to find maximum profit by cutting the rod of different length in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 10:24:57

755 Views

Suppose we have a rod is given of length n. We also have a list, that contains different size and price for each size. We have to find the maximum price by cutting the rod and selling them in the market. To get the best price by making a cut ... Read More

Program to find minimum number of rocketships needed for rescue in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 10:23:11

173 Views

Suppose we have a list of numbers called weights this is representing peoples' weights and a value limit determines the weight limit of one rocket ship. Now each rocketship can take at most two people. We have to find the minimum number of rocket ships it would take to rescue ... Read More

Program to reverse linked list by groups of size k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:55:37

409 Views

Suppose we have a singly linked list, and another value k, we have to reverse every k contiguous group of nodes.So, if the input is like List = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k = 3, then the output will be [3, 2, 1, 6, ... Read More

Program to reverse the directed graph in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:53:25

1K+ Views

Suppose we have a directed graph, we have to find its reverse so if an edge goes from u to v, it now goes from v to u. Here input will be an adjacency list, and if there are n nodes, the nodes will be (0, 1, ..., n-1).So, if ... Read More

Program to reverse a linked list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:51:14

543 Views

Suppose we have a linked list, we have to reverse it. So if the list is like 2 -> 4 -> 6 -> 8, then the new reversed list will be 8 -> 6 -> 4 -> 2.To solve this, we will follow this approach −Define one procedure to perform ... Read More

Program to find string after removing consecutive duplicate characters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:48:27

422 Views

Suppose we have a string s, we repeatedly delete the first consecutive duplicate characters. We have to find the final string.So, if the input is like s = "xyyyxxz", then the output will be "z", as "yyy" are the first consecutive duplicate characters which will be deleted. So we have ... Read More

Program to count minimum invalid parenthesis to be removed to make string correct in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 10:45:21

446 Views

Suppose we have a string of parentheses; we have to write a function to compute the minimum number of parentheses to be removed to make the string correct (each open parenthesis is eventually closed).So, if the input is like "(()))(", then the output will be 2, as the correct string ... Read More

Advertisements