Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 311 of 377

Program to convert hour minutes’ time to text format in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 07-Oct-2021 700 Views

Suppose we have two inputs hour and minutes. We have to show the time in text format. This is like −8:00 : 8'o clock8:01 : one minute past eight8:10 : ten minutes past eight8:15 : quarter past eight8:30 : half past eight8:40 : twenty minutes to nine8:45 : quarter to nine8:47 : thirteen minutes to nine8:28 : twenty eight minutes past eightSo, if the input is like h = 9, m = 42, then the output will be eighteen minutes to tenTo solve this, we will follow these steps −text:= a list containing texts for 30 different numeric values as ...

Read More

Program to check whether two sentences are similar or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 07-Oct-2021 1K+ Views

Suppose we have two sentences s and t. We have to check whether they are similar or not. Here sentence has only English letters. Two sentences are said to be similar when it is possible to add an arbitrary sentence (possibly empty) inside one of these given sentences such that the two sentences become equal.So, if the input is like s = "we live at city Kolkata" t = "city Kolkata", then the output will be True because we can get s from t by adding sentence "we live in".To solve this, we will follow these steps −s1 := a ...

Read More

Program to find minimum remove required to make valid parentheses in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 07-Oct-2021 466 Views

Suppose we have a string s with parenthesis '(' , ')' and lowercase English characters. We have to delete the minimum number of parentheses ( '(' or ')', from any positions ) so that the resulting parentheses string is valid and have to finally return any valid string. Here the parentheses string is valid when all of these criteria are fulfilled −The string is empty and contains lowercase characters only, orThe string can be written as AB (A concatenated with B), where A and B are valid strings, orThe string can be written as the form of (A), where A ...

Read More

Program to find how many swaps needed to sort an array in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 07-Oct-2021 2K+ Views

Suppose, we have an array called nums and we have to find the number of swaps needed to make nums sorted in any order, either ascending or descending.So, if the input is like nums = [2, 5, 6, 3, 4], then the output will be 2 because initially nums has [2, 5, 6, 3, 4]. If we swap numbers 6 and 4, the array will be [2, 5, 4, 3, 6]. Then, if we swap the numbers 5 and 3, the array will be [2, 3, 4, 5, 6]. So 2 swaps are needed to make the array sorted in ...

Read More

Program to find numbers with same consecutive differences in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 07-Oct-2021 428 Views

Suppose we have to find an array of size N such that the absolute difference between every two consecutive digits is K. Every number in the answer must not have leading zeros except for the number 0 itself.So, if the input is like N = 4 K = 7, then the output will be [1818, 2929, 7070, 8181, 9292], here 0707 is not valid as it has leading 0.To solve this, we will follow these steps −if N is same as 1, thenreturn a new list from range 0 to 9queue := make a queue with all elements from 1 ...

Read More

Program to find maximum value at a given index in a bounded array in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 07-Oct-2021 436 Views

Suppose we have three values, n, index and maxSum. Consider an array called nums we have to find nums[index] and nums satisfies the following conditions −size of nums is nAll elements in n is positive.|nums[i] - nums[i+1]|

Read More

Program to find out the number of accepted invitations in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 07-Oct-2021 390 Views

Suppose there are m boys and n girls, and m = n. There is a party incoming, and each boy has to go with a girl to that party. So, the boys invite all the girls and a girl can accept one invitation only. We have to find out the total number of invitations from the boys that the girls can accept. The input is given in a m x n matrix, where each cell position i, j denotes if the boy i has sent a letter to girl j. If a cell is 1 it means that an invitation ...

Read More

Program to find partition array into disjoint intervals in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 07-Oct-2021 313 Views

Suppose we have an array nums, we have to partition it into two different subarrays called left and right such that −Each element in left subarray is less than or equal to each element in right subarray.left and right subarrays are non-empty.left subarray has the smallest possible size.We have to find the length of left after such a partitioning.So, if the input is like nums = [5, 0, 3, 8, 6], then the output will be 3 because left array will be [5, 0, 3] and right subarray will be [8, 6].To solve this, we will follow these steps −mx ...

Read More

Program to find maximum number of consecutive values you can make in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 07-Oct-2021 497 Views

Suppose we have an array called coins with n elements, and it is representing the coins that we own. The value of the ith coin is denoted as coins[i]. We can make some value x if we can select some of our n coins such that their values sum up to x. We have to find the maximum number of consecutive values that we can get with the coins starting from and including 0.So, if the input is like coins = [1, 1, 3, 4], then the output will be 10, because0 = []1 = [1]2 = [1, 1]3 = ...

Read More

Program to find out the number of pairs of equal substrings in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 07-Oct-2021 392 Views

Suppose we are given two strings, both made of lowercase alphabets. We have to find out the number of quadruples (p, q, r, s) satisfying the given conditions −0

Read More
Showing 3101–3110 of 3,768 articles
« Prev 1 309 310 311 312 313 377 Next »
Advertisements