Arnab Chakraborty has Published 4293 Articles

Total Distance to Visit City Blocks in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 10:58:41

231 Views

Suppose we have a matrix of unique strings representing the city blocks, and another list of strings containing blocks to visit. If we are at block matrix[0][0], then find the total Manhattan distance required to visit every block in order.So, if the input is likeQBCDEZGGiBlock = [H, B, C]Then the ... Read More

Split String of Size N in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Sep-2020 10:56:36

1K+ Views

Suppose we have a string s and an integer n, we have to split the s into n-sized pieces.So, if the input is like s = "abcdefghijklmn", n = 4, then the output will be ['abcd', 'efgh', 'ijkl', 'mn']To solve this, we will follow these steps −i:= 0f:= a new ... Read More

Changing Directions in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 13:28:44

878 Views

Suppose we have a list of numbers called nums, we have to find the number of times that the list changes from positive-to-negative or negative-to-positive slope.So, if the input is like [2, 4, 10, 18, 6, 11, 13], then the output will be 2, as it changes the direction at ... Read More

Cell fusion in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 13:25:50

195 Views

Suppose we have a list of numbers called cells; this list is representing sizes of different cells. Now, in each iteration, the two largest cells a and b interact according to these rules: So, If a = b, they both die. Otherwise, the two cells merge and their size becomes ... Read More

camelCase in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 13:21:45

9K+ Views

Suppose we have a list of words, we have to concatenate them in camel case format.So, if the input is like ["Hello", "World", "Python", "Programming"], then the output will be "helloWorldPythonProgramming"To solve this, we will follow these steps −s := blank stringfor each word in words −make first letter word ... Read More

Caesar Cipher in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 13:20:03

1K+ Views

Suppose we have a lowercase alphabet string s, and an offset number say k. We have to replace every letter in s with a letter k positions further along the alphabet. We have to keep in mind that when the letter overflows past a or z, it gets wrapped around ... Read More

Buying Cars in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 13:18:08

407 Views

Suppose we have a list of prices of cars for sale, and we also have a budget k, we have to find the maximum number of cars we can buy.So, if the input is like [80, 20, 10, 30, 80], k = 85, then the output will be 3 as ... Read More

Boss Fight in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 13:15:57

658 Views

Suppose we have a binary list called fighters and another list of binary lists called bosses. In fighters list the 1 is representing a fighter. Similarly, in bosses list 1 representing a boss. That fighters can beat a boss’s row if it contains more fighters than bosses. We have to ... Read More

Book Pagination in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 13:13:36

1K+ Views

Suppose we have a list of strings called book, if we page an index (0-indexed) into the book, and page_size, we have to find the list of words on that page. If the page is out of index then simply return an empty list.So, if the input is like book ... Read More

Bob's Game in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 13:11:41

648 Views

Suppose we have a friend named Bob, and he is playing a game with himself. He gives himself a list of numbers called nums. Now in each turn, Bob selects two elements of the list and replaces them with one positive integer with the same sum as the numbers he ... Read More

Advertisements