Arnab Chakraborty has Published 4452 Articles

Program to find maximum how many water bottles we can drink in Python

Arnab Chakraborty

Arnab Chakraborty

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

519 Views

Suppose there are n number of full water bottles, we can exchange m empty water bottles for only one full water bottle. Now drinking a full water bottle makes it an empty bottle. We have to find the maximum number of water bottles we can drink.So, if the input is ... Read More

Program to find number of good pairs in Python

Arnab Chakraborty

Arnab Chakraborty

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

3K+ Views

Suppose we have an array nums. Here a pair (i, j) is said to be a good pair if nums[i] is same as nums[j] and i < j. We have to count the number of good pairs.So, if the input is like nums = [5, 6, 7, 5, 5, 7], ... Read More

Program to reformat date in YYYY-MM-DD format using Python

Arnab Chakraborty

Arnab Chakraborty

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

1K+ Views

Suppose we have a date string in the format "Day Month Year" format where day's are like [1st, 2nd, ..., 30th, 31st], months are in [Jan, Feb, ... Nov, Dec] format and year is a four-digit numeric value in range 1900 to 2100, we have to convert this date into ... Read More

Program to check we can make arithmetic progression from sequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:22:01

2K+ Views

Suppose we have a list of numbers called nums. We have to check whether the elements present in nums are forming AP series or not. As we know in AP (Arithmetic Progression) series the common difference between any two consecutive elements is the same.So, if the input is like nums ... Read More

Program to find average salary excluding the minimum and maximum salary in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:14:34

2K+ Views

Suppoe we have an array with distinct elements called salary where salary[i] is the salary of ith employee. We have to find the average salary of employees excluding the minimum and maximum salary.So, if the input is like salary = [8000, 6000, 2000, 8500, 2500, 4000], then the output will ... Read More

Program to perform XOR operation in an array using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-May-2021 12:14:00

643 Views

Suppose we have an integer n and another integer start. We have to create an array called nums where nums[i] = start + 2*i (i start from 0) and n is the size of nums. Then find the bitwise XOR of all elements of nums.So, if the input is like ... Read More

Program to find running sum of 1d array in Python

Arnab Chakraborty

Arnab Chakraborty

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

3K+ Views

Suppose we have an array nums. The running sum of an array as rs[i] is sum of all elements from nums[0] to nums[i]. Finally return the entire running sum of nums.So, if the input is like nums = [8, 3, 6, 2, 1, 4, 5], then the output will be ... Read More

Program to find Final Prices With a Special Discount in a Shop in Python

Arnab Chakraborty

Arnab Chakraborty

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

853 Views

Suppose we have an array called prices where prices[i] represents price of the ith item in a shop. There is a special offer going on, if we buy the ith item, then we will get a discount equivalent to prices[j] where j is the minimum index such that j > ... Read More

Program to delete n nodes after m nodes from a linked list in Python

Arnab Chakraborty

Arnab Chakraborty

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

234 Views

Suppose we are given a linked list that has the start node as "head", and two integer numbers m and n. We have to traverse the list and delete some nodes such as the first m nodes are kept in the list and the next n nodes after the first ... Read More

Day of the Week in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Feb-2021 07:24:45

6K+ Views

Suppose we have a date (day, month and year). From this date, we have to find the day of the week of that given date. To solve this we will use Zeller’s Algorithm. The formula to find weekday using Zeller’s Algorithm is here𝑤=$$\lgroup d+\lfloor \frac{13(m+1)}{5} \rfloor+y+\lfloor\frac{y}{4} \rfloor+\lfloor\frac{c}{4} \rfloor+5c \rgroup mod ... Read More

Advertisements