Arnab Chakraborty has Published 4452 Articles

Program to find diagonal sum of a matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:53:35

9K+ Views

Suppose we have a square matrix; we have to find the sum of the matrix diagonals. So only include the sum of all of the elements on the primary diagonal and all the elements on the secondary diagonal and ignore the crossing element.So, if the input is like10596815323812321173then the output ... Read More

Program to check pattern of length m repeated K or more times exists or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:53:11

140 Views

Suppose we have an array nums with positive values, we have to find a pattern of length m that is repeated k or more than k times. Here a pattern is a non-overlapping subarray (consecutive) that consists of one or more values and are repeated multiple times. A pattern is ... Read More

Program to find most visited sector in a circular track using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:52:52

185 Views

Suppose we have a number n and an array called rounds. We have a circular track which consists of n different sectors labeled from 1 to n. Now consider a race will be held on this track, the race consists of m different rounds. The ith round starts at sector ... Read More

Program to find number with thousand separator in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:51:49

404 Views

Suppose we have a number n, we have to return this number into string format where thousands are separated by comma (", ").So, if the input is like n = 512462687, then the output will be "512, 462, 687"To solve this, we will follow these steps −res := n as ... Read More

Program to find a good string from a given string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:30:33

928 Views

Suppose we have a string s with lower and upper case English letters. We shall consider a string is a good string which does not have any two adjacent characters s[i] and s[i + 1] where −0

Program to find kth missing positive number in an array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:30:13

493 Views

Suppose we have an array called nums with positive sorted strictly increasing values, and also have an integer k. We have to find the kth positive integer that is missing from this array.So, if the input is like nums = [1, 2, 4, 8, 12], k = 6, then the ... Read More

Program to find number of good triplets in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:29:49

2K+ Views

Suppose we have an array nums, and three different integers a, b and c. We have to find the number of good triplets. A triplet (nums[i], nums[j], nums[k]) is said to be a good triplet if the following conditions are true −0

Program to check three consecutive odds are present or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:29:21

480 Views

Suppose we have an array called nums, we have to check whether there are three consecutive odd numbers in nums or not.So, if the input is like nums = [18, 15, 2, 19, 3, 11, 17, 25, 20], then the output will be True as there are three consecutive odds ... Read More

Program to shuffle string with given indices in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:28:54

941 Views

Suppose we have a string s and a list of indices ind, they are of same length. The string s will be shuffled such that the character at the position i, moves to indices[i] in the final string. We have to find the final string.So, if the input is like ... Read More

Program to count odd numbers in an interval range using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:23:37

1K+ Views

Suppose we have two non-negative numbers left and right. We have to find the number of odd numbers between left and right (inclusive).So, if the input is like left = 3, right = 15, then the output will be 7 because there are 7 odd numbers in range, these are ... Read More

Advertisements