Arnab Chakraborty has Published 4293 Articles

Pattern After Double, Reverse, and Swap in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 11:30:12

187 Views

Suppose we have a number n, we have ot find the nth value from the sequence. The sequence is like below −xxyxxyxxyyxxyxxxyyxyyxyyxyyxyyxyy...To generate the next value, we have to follow these rules, starting with xxy as the first term −When we are at the start of the pattern, double it(concatenate ... Read More

Domino Covering Board in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 11:26:36

241 Views

Suppose we have two numbers n and m representing a board of size n x m. We also have an unlimited number of 1 x 2 dominos. We have to find the maximum number of dominos that can be placed on the board such that they don't overlap and every ... Read More

Detect Voter Fraud in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 11:21:02

273 Views

Suppose we have a list of votes, where each element in the list has two elements [c_id, v_id], the c_id is the candidate id and v_id is the voter id. We have to check whether any voter has voted more than once or not.So, if the input is like [[5, ... Read More

Counting Number of Dinosaurs in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 11:14:18

246 Views

Suppose we have a string called animals and another string called dinosaurs. Every letter in animals represents a different type of animal and every unique character in dinosaurs string represents a different dinosaur. We have to find the total number of dinosaurs in animals.So, if the input is like animals ... Read More

Count Elements x and x+1 Present in List in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 11:12:50

174 Views

Suppose we have a list of numbers called nums, we have to find the number of elements x there are such that x + 1 exists as well.So, if the input is like [2, 3, 3, 4, 8], then the output will be 3To solve this, we will follow these ... Read More

Cell Count After Removing Corner Diagonals in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 11:11:25

132 Views

Suppose we have a number n representing the length of an n x n board. We have to delete all cells that are diagonal to one of the four corners and return the number of empty cells.So, if the input is like n = 4, XOOXOXXOOXXOXOOXThen the output will be ... Read More

Connell sequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 11:06:14

540 Views

Suppose we have a number n, we have to find the nth term of Connell sequence. The Connell sequence is as follows: 1. Take first odd integer: 1 2. Take next two even integers 2, 4 3. Then take the next three odd integers 5, 7, 9 4. After that ... Read More

Common Words in Two Strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 11:04:19

6K+ Views

Suppose we have two strings s0 and s1, they are representing a sentence, we have to find the number of unique words that are shared between these two sentences. We have to keep in mind that, the words are case-insensitive so "tom" and "ToM" are the same word.So, if the ... Read More

Column Sort of a Matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 11:02:40

2K+ Views

Suppose we have a matrix, we have to sort each of the columns in ascending order.So, if the input is like1121316641118then the output will be1646118112131To solve this, we will follow these steps −R := row count of matrix, C := column count of matrixres := matrix of same size as ... Read More

Collatz sequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 11:00:19

2K+ Views

Suppose we have a positve integer n, we have to find the length of its Collatz sequence. As we know Collatz sequence is generated sequentially where n = n/2 when n is even otherwise n = 3n + 1. And this sequence ends when n = 1.So, if the input ... Read More

Advertisements