Arnab Chakraborty has Published 4293 Articles

Climbing Stairs in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 16:04:36

734 Views

There are n stairs. One person will go to 1st to nth stairs. Maximum how many stairs he/she can cross in one step is also given. With this information, we have to find possible ways to go to the nth stairs. Let us consider one can cross a maximum two ... Read More

Sqrt(x) in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 16:03:55

521 Views

Suppose we have a number x, and x is a non-negative number. We have to find the square root of x without using any library functions. So we have to create our own function to evaluate sqrt(x). In this function, the decimal digit of the output will be truncated.Suppose the ... Read More

Plus One in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 16:02:33

2K+ Views

Suppose we have an array of integers, say A. A will hold n elements, and they are non-negative. The whole array A is representing one large number. So if A = [5, 3, 2, 4] is given, it indicates the number 5324. We have to take that array A, then ... Read More

Maximum Subarray in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 16:01:53

4K+ Views

Suppose we have an integer array A. We have to find the contiguous subarrays which length will be at least one, and that has the largest sum, and also return its sum. So if the array A is like A = [-2, 1, -3, 4, -1, 2, 1, -5, 4], ... Read More

Count and Say in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 16:00:49

1K+ Views

Here we will see the Count and Say sequence. This is a sequence whose few terms are like below −111211211111221The string will be read like1 (One)11 (One 1) So read the previous 1, and say “One 1”21 (Two 1) So read the previous 11, and say “Two 1”1211 (One 2 ... Read More

Implement strStr() in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 16:00:13

2K+ Views

Suppose we have two strings str and sub_str. We have to find the first occurrence of sub_str in the str. So if the string str is “helloworld”, and substring is “lo”, then the result will be 3.This can be done using the strstr() function in C. We have to design ... Read More

Merge Two Sorted Lists in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 15:58:23

1K+ Views

Suppose we have two sorted lists A and B. We have to merge them and form only one sorted list C. The size of lists may different.For an example, suppose A = [1, 2, 4, 7] and B = [1, 3, 4, 5, 6, 8], then merged list C will ... Read More

Longest Common Prefix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 15:50:24

7K+ Views

Suppose we have a set of strings in an array. We have to find the Longest Common Prefix amongst the string in the array. Here we will assume that all strings are lower case strings. And if there is no common prefix, then return “”.So if the array of a ... Read More

Minimum Moves to Equal Array Elements II in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 13:41:57

461 Views

Suppose we have a non-empty integer array, we have to find the minimum number of moves that are required to make all array elements equal, where a move is incrementing or decrementing a selected element by 1. So when the array is like [1, 2, 3], then the output will ... Read More

Min Stack in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 13:27:30

3K+ Views

Here we will see how to make a stack, that can perform push, pop, top, and retrieve the min element in constant time. So the functions will be push(x), pop(), top() and getMin()To solve this, we will follow these steps −Initialize the stack by min element as infinityFor push operation ... Read More

Advertisements