Arnab Chakraborty has Published 4293 Articles

Program to find number of arithmetic sequences from a list of numbers in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 07:16:50

2K+ Views

Suppose we have a list of numbers called nums, we have to find the number of contiguous arithmetic sequences of length ≥ 3. As we know an arithmetic sequence is a list of numbers where the difference between one number and the next number is the same.So, if the input ... Read More

Program to find start indices of all anagrams of a string S in T in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Nov-2020 10:51:25

264 Views

Suppose we have two strings S and T, we have to find all the start indices of S's anagrams in T. The strings consist of lowercase letters only and the length of both strings S and T will not be larger than 20 and 100.So, if the input is like ... Read More

Program to find numbers represented as linked lists in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Nov-2020 10:46:03

152 Views

Suppose we have two singly linked list L1 and L2, each representing a number with least significant digits first, we have to find the summed linked list.So, if the input is like L1 = [5, 6, 4] L2 = [2, 4, 8], then the output will be [7, 0, 3, ... Read More

Program to find number of subsequences with i, j and k number of x, y, z letters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Nov-2020 10:41:06

184 Views

Suppose we have a string s with "x", "y" and "z"s, we have to find the number of subsequences that have i number of "x" characters, followed by j number of "y" characters and followed by k number of "z" characters where i, j, k ≥ 1.So, if the input ... Read More

Program to find next board position after sliding the given direction once in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Nov-2020 10:36:31

179 Views

Suppose we have a 2048 game board representing the initial board and a string direction representing the swipe direction, we have to find the next board state. As we know in the 2048 game, we are given a 4 x 4 board of numbers (some of them are empty, represented ... Read More

Program to convert each element in row and column to zero for zero values in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Nov-2020 10:28:02

518 Views

Suppose we have a 2D matrix of numbers, now for each zero in the given matrix and replace all values in its row and column with zero, and return the final matrix.So, if the input is like matrix, then the output will be matrix as the 0th, 2nd and 3rd ... Read More

Program to check whether given list is in valid state or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:31:10

397 Views

Suppose we have a list of numbers called nums, we have to check whether every number can be grouped using one of the following rules: 1. Contiguous pairs (a, a) 2. Contiguous triplets (a, a, a) 3. Contiguous triplets (a, a + 1, a + 2)So, if the input is ... Read More

Program to find all upside down numbers of length n in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:29:07

298 Views

Suppose we have a value n. We have to find all upside down numbers of length n. As we knot the upside down number is one that appears the same when flipped 180 degrees.So, if the input is like n = 2, then the output will be ['11', '69', '88', ... Read More

Program to check all values in the tree are same or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:27:00

305 Views

Suppose we have a binary tree, we have to check whether all nodes in the tree have the same values or not.So, if the input is likethen the output will be TrueTo solve this, we will follow these steps −Define a function solve() . This will take root, and valif ... Read More

Program to check occurrences of every value is unique or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:24:48

291 Views

Suppose we have a list of numbers nums (positive or negative), we have to check whether the number of occurrences of every value in the array is unique or not.So, if the input is like nums = [6, 4, 2, 9, 4, 2, 2, 9, 9, 9], then the output ... Read More

Advertisements