Arnab Chakraborty has Published 4452 Articles

Program to find total area covered by two rectangles in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:46:25

273 Views

Suppose we want to find the total area covered by two rectilinear rectangles in a 2D plane. Here each rectangle is defined by its bottom left corner and top right corner as shown in the figure.To solve this, we will follow these steps −width_1 := |C-A|, height_1 := |D-B|width_2 := ... Read More

Program to find maximum size of any sequence of given array where every pair is nice in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:41:00

172 Views

Suppose we have a sequence nums of size n. We have to find the maximum size of subsequence of nums in which every pair (p, q) is a nice pair? A pait is said to be nice pair if and only if it holds at least one of these conditions: ... Read More

Program to find modulus of a number by concatenating n times in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:31:57

123 Views

Suppose we have a number A. We have to generate a large number X by concatenating A, n times in a row and find the value of X modulo m.So, if the input is like A = 15 n = 3 m = 8, then the output will be 3, ... Read More

Program to find number of ways we can select sequence from Ajob Sequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:29:05

139 Views

Suppose there is a strange language called Ajob language. It has infinite number of letters. We know n words in this language. The first word is one character long, second one is two character long and so on. And all letters in a word are unique. If we select any ... Read More

Program to check n can be shown as sum of k or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:25:30

78 Views

Suppose we have a number n, and another number k. We have to check whether n can be represented as a sum of k prime numbers or not.So, if the input is like n = 30 k = 3, then the output will be True because 30 can be represented ... Read More

Program to find number of pairs between x, whose multiplication is x and they are coprime in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:22:19

129 Views

Suppose there is a function f(x), that counts number of (p, q) pairs, such that1 < p

Program to find number of possible BSTs can be generated using n distinct nodes in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:17:54

66 Views

Suppose we have a number n. If we have numbers like [1, 2, ..., n] we have to count number ofpossible BSTs can be formed using these n values. If the answer is too large, then mod the result by 10^9+7.So, if the input is like n = 3, then ... Read More

Program to find out the position of a ball after n reversals in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:12:19

164 Views

Suppose, there are n number of balls. The balls are ordered in a fashion 1, 2, 3, 4, ..., n. Now the balls are reversed in order, or ordered in a way n, n-1, n-2, ......, 2, 1. The balls are again reversed in order, this time they are reversed ... Read More

Program to reset a polygon to its initial state in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:05:20

116 Views

Suppose, there is a polygon with n vertices, n flipping axis, and n rotation points. The following are true for the flipping axes and rotation pointsIf n is odd, each flipping axis passes through only one vertex and the middle of the opposite side.If n is even, half of the ... Read More

Program to find out the cells containing maximum value in a matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 07:58:07

207 Views

Suppose, there is a n x n matrix initialized with 0s. Now, a list is given and it contains some pairs that contain a particular row and a column position. For each item i in the list, the contents of the cells increase by 1 where the row number and ... Read More

Advertisements