Arnab Chakraborty has Published 4452 Articles

Program to find nearest time by reusing same digits of given time in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 08:22:21

261 Views

Suppose we have a 24-hour string in "hh:mm" format, we have to find the next closest time that can be formed by reusing given digits. We can reuse digits from the given string as many times as we want.So, if the input is like s = "03:15", then the output ... Read More

Program to find minimum number of days to wait to make profit in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 08:18:33

182 Views

Suppose we have a list of prices representing the daily stock market prices of a company in chronological sequence. We have to find a same length list where the value at index i will be the minimum number of days we would have to wait until we make a profit. ... Read More

Program to find all possible strings typed using phone keypad in python

Arnab Chakraborty

Arnab Chakraborty

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

852 Views

Suppose we have a string containing digits from 2-9. We have to find all possible letter combinations that the number could generate. One mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does map some characters but no letters.12a b c3d e ... Read More

Program to check whether a board is valid N queens solution or not in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 08:12:22

662 Views

Suppose we have a n x n matrix represents a chess board. There are some 1s and 0s, where 1 represents a queen and 0 represents an empty cell. We have to check whether the board is valid solution to the N-Queen puzzle or not. As we know a board ... Read More

Program to check whether we can unlock all rooms or not in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 08:08:16

187 Views

Suppose we have a list of lists called rooms. Each index i in rooms represents a room and rooms[i] represents different keys to open other rooms. The room 0 is open and we are at that room and every other room is locked. We can move freely between opened rooms; ... Read More

Program to find nth ugly number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 08:06:06

231 Views

Suppose we have a number n; we have to find the nth ugly number. As we know that the ugly numbers are those numbers, whose prime factors are only 2, 3 and 5. So if we want to find 10th ugly number, the output will be 12, as the first ... Read More

Program to find median of two sorted lists in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:56:38

159 Views

Suppose we have two sorted lists. We have to find the median of these two lists. So if the arrays are like [1, 5, 8] and [2, 3, 6, 9], then the answer will be 5.To solve this, we will follow these steps:Define a function solve(), this will take an ... Read More

Program to generate tree using preorder and inorder traversal in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:51:32

141 Views

Suppose we have the preorder and inorder traversal of a binary tree. We have to recover the tree from these sequences. So if the preorder and inorder sequences are [3, 9, 20, 15, 7] and [9, 3, 15, 20, 7], then the tree will be:Let us see the steps:Define a ... Read More

Program to check whether given list of blocks are symmetric over x = y line or not in python

Arnab Chakraborty

Arnab Chakraborty

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

297 Views

Suppose we have a list of numbers called nums. And it is representing the height of square blocks, we have to check whether the shape is symmetric over the y = x line or not.So, if the input is like nums = [7, 5, 3, 2, 2, 1, 1], then ... Read More

Program to count number of consecutive lists whose sum is n in C++

Arnab Chakraborty

Arnab Chakraborty

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

299 Views

Suppose we have a number n, we have to find the number of lists of positive consecutive values that sum up to n.So, if the input is like n = 15, then the output will be 4, as The possible lists are: [1, 2, 3, 4, 5], [4, 5, 6], ... Read More

Advertisements