Arnab Chakraborty has Published 4293 Articles

Program to make target by removing from first or last and inserting again in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 12:27:15

133 Views

Suppose we have two strings S and T and they are permutations of each other. Suppose there is an operation where we remove either the first or the last character in S and insert it anywhere in the string. Then find the minimum number of operations needed to convert S ... Read More

Program to delete all leaves with even values from a binary tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 11:55:18

392 Views

Suppose we have we have a binary tree, we will repeatedly delete all leaves that have even values. After deleting all, if it has only root with even values, that will be deleted also.So, if the input is likethen the output will beTo solve this, we will follow these steps ... Read More

Program to find number of ways we can decode a message in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 11:45:07

352 Views

Suppose we have mapping like 'a' = 1, 'b' = 2, ... 'z' = 26, and we have an encoded message message string, we have to count the number of ways it can be decoded.So, if the input is like message = "222", then the output will be 3, as ... Read More

Program to check two parts of a string are palindrome or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 11:07:03

338 Views

Suppose we have two strings S and T of same length, we have to check whether it is possible to cut both strings at a common point so that the first part of S and the second part of T form a palindrome.So, if the input is like S = ... Read More

Program to check whether we can take all courses or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 11:03:47

177 Views

Suppose we have a 2D matrix where matrix[i] represents the list of prerequisite courses needed to enroll course i. Now, we have to check whether it is possible to take all courses or not.So, if the input is like matrix = [[1], [2], []], then the output will be True, ... Read More

Program to find a sublist where first and last values are same in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 10:55:10

214 Views

Suppose we have a list of numbers called nums, we have to find the number of sublists where the first element and the last element are same.So, if the input is like nums = [10, 15, 13, 10], then the output will be 5, as the sublists with same first ... Read More

Program to find duplicate element from n+1 numbers ranging from 1 to n in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:31:30

284 Views

Suppose we have a list of numbers called nums of length n + 1. These numbers are picked from range 1, 2, ..., n. As we know, using the pigeonhole principle, there must be a duplicate. We have to find that and return it.So, if the input is like [2, ... Read More

Program to find all words which share same first letters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:29:41

420 Views

Suppose we have a list of words in lowercase letters, we have to find the length of the longest contiguous sublist where all words have the same first letter.So, if the input is like ["she", "sells", "seashells", "on", "the", "seashore"], then the output will be 3 as three contiguous words ... Read More

Program to check programmers convention arrangements are correct or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:28:09

116 Views

Suppose we have a number n, this is representing programmers looking to enter a convention, and we also have a list of number, convention 1 represents a programmer and 0 represents empty space. Now the condition is no two programmers can sit next to each other, we have to check ... Read More

Program to find the formatted amount of cents of given amount in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:26:17

403 Views

Suppose we have a positive number n, where n is representing the amount of cents we have, we have to find the formatted currency amount.So, if the input is like n = 123456, then the output will be "1, 234.56".To solve this, we will follow these steps −cents := n ... Read More

Advertisements