Arnab Chakraborty has Published 4452 Articles

Program to find number of unique four indices where they can generate sum less than target from four lists in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:43:54

128 Views

Suppose we have four list of numbers A, B, C and D and also have another number target. We have to find the number of different unique indices i, j, k, l such that A[i] + B[j] + C[k] + D[l] ≤ target.So, if the input is like A = ... Read More

Program to print matrix elements in spiral order in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:39:27

2K+ Views

Suppose we have a 2D matrix mat. We have to print the matrix elements in a spiral way. At first starting from the first row (mat[0, 0]), print the whole content and then follow the last column to print, then the last row, and so on, thus it prints the ... Read More

Program to sort a given linked list into ascending order in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:34:29

4K+ Views

Suppose we have a linked list. We have to sort the list into ascending order.So, if the input is like [5, 8, 4, 1, 5, 6, 3], then the output will be [1, 3, 4, 5, 5, 6, 8, ]To solve this, we will follow these steps:values := a new ... Read More

Program to find number of items left after selling n items in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:31:35

2K+ Views

Suppose we have a list of numbers called items and another value n. A salesman has items in a bag with random IDs. The salesman can delete as many as n items from the bag. We have to find the minimum number of different IDs in the bag after n ... Read More

Program to find second deepest node in a binary tree in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:29:14

241 Views

Suppose we have a binary tree; we have to find the depth of the second deepest leaf. If there are multiple deepest leaves, the second deepest leaf node will be the next highest one. As we know the root has a depth of 0.So, if the input is likethen the ... Read More

Program to check whether leaves sequences are same of two leaves or not in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:21:57

80 Views

Suppose we have two binary trees; we have to check whether the sequence of leaves left-to-right in both trees are the same.So, if the input is likethen the output will be True as the sequence is [2, 6] for both trees.To solve this, we will follow these steps:c := a ... Read More

Program to reverse words separated by set of delimiters in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:16:15

234 Views

Suppose we have a string and a set of delimiters, we have to reverse the words in the string while the relative ordering of the delimiters should not be changed.So, if the input is like s = "Computer/Network:Internet|tutorialspoint" delims = ["/", ":", '|'], then the output will be tutorialspoint/Internet:Network|ComputerTo solve ... Read More

Program to reverse inner nodes of a linked list in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:12:45

120 Views

Suppose we have linked list, we also have two values i and j, we have to reverse the linked list from i to jth nodes. And finally return the updated list.So, if the input is like [1, 2, 3, 4, 5, 6, 7, 8, 9] i = 2 j = ... Read More

Program to evaluate ternary expression in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:09:04

226 Views

Suppose we have an expression that holds the ternary expression, we have to evaluate the result of the expression. It supports some values like T and F for True and False and “?” and “:” characters. There are some properties:The length of the given string must be less than or ... Read More

Program to check we can update a list index by its current sum to reach target or not in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:04:42

78 Views

Suppose we have a list of numbers called target. Now let us consider a list X with the same length as given list and X is filled with 1s. We can perform the following operation as many times as we want: Take any index i in X and set X[i] ... Read More

Advertisements