Arnab Chakraborty has Published 4293 Articles

Program to find first positive missing integer in range in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 10:28:27

346 Views

Suppose we have a list of sorted list of distinct integers of size n, we have to find the first positive number in range [1 to n+1] that is not present in the array.So, if the input is like nums = [0, 5, 1], then the output will be 2, ... Read More

Program to find lowest possible integer that is missing in the array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 10:25:57

191 Views

Suppose we have a list of numbers called nums, we have to find the first missing positive number. In other words, the lowest positive number that does not present in the array. The array can contain duplicates and negative numbers as well.So, if the input is like nums = [0, ... Read More

Program to find the maximum number in rotated list in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 10:23:53

122 Views

Suppose there is an array, and that is sorted, consider that array is rotated at some pivot, that is unknown to us. So we have to find the maximum from that rotated array. So if the array is like[3, 4, 5, 1, 2], then the output will be 5.To solve ... Read More

Program to find minimum amount needed to be paid all good performers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 10:20:11

376 Views

Suppose we have given a list of numbers called ratings, and this is showing the performance scores of coders. Now the manager wants to give Rs 1000 to every coder except if two coders are adjacent, they would like to pay the better performing coder at least Rs 1000 higher ... Read More

Program to check a number can be written as a sum of distinct factorial numbers or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 10:17:12

236 Views

Suppose we have a positive number n, we have to check whether n can be written as the sum of unique positive factorial numbers or not.So, if the input is like n = 144, then the output will be True, as 4! + 5! = 24 + 120 = 144To ... Read More

Program to find the sum of the absolute differences of every pair in a sorted list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 14:31:59

234 Views

Suppose we have a list of sorted numbers called nums, we have to find the sum of the absolute differences between every pair of numbers in the given list. Here we will consider (i, j) and (j, i) are different pairs. If the answer is very large, mod the result ... Read More

Program to check robot can reach target position or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:47:26

442 Views

Suppose we have a robot, that is currently sitting in at position (0, 0) (Cartesian plane). If we have list of its moves that it can make, containing N(North), S(South), W(West), and E(East). We have to check whether it can reach at destination coordinate (x, y).So, if the input is ... Read More

Program to check we can reach leftmost or rightmost position or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:44:57

371 Views

Suppose we have a string containing letters of three types, R, B, and dot(.). Here R stands for our current position, B stands for a blocked position, and dot(.) stands for an empty position. Now, in one step, we can move to any adjacent position to our current position, as ... Read More

Program to find how many years it will take to reach t amount in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:43:46

227 Views

Suppose we have some parameters P, O, E, T. If we have P dollars in principal that we want to invest the stock market. The stock market alternates between first returning E and then O percent interest per year, we have to check how many years it would take to ... Read More

Program to reverse the position of each word of a given string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:42:28

653 Views

Suppose we have a string of words delimited by spaces; we have to reverse the order of words.So, if the input is like "Hello world, I love python programming", then the output will be "programming python love I world, Hello"To solve this, we will follow these steps −temp := make ... Read More

Advertisements