Arnab Chakraborty has Published 4452 Articles

Check if a Queen can attack a given cell on chessboard in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:00:31

565 Views

Suppose we have two coordinates on a chessboard for queen and opponent. These points are Q and O respectively. We have to check whether the queen can attack the opponent or not. As we know that the queen can attack in the same row, same column and diagonally.So, if the ... Read More

Check if a prime number can be expressed as sum of two Prime Numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 12:58:49

712 Views

Suppose we have a prime number n. we have to check whether we can express n as x + y where x and y are also two prime numbers.So, if the input is like n = 19, then the output will be True as we can express it like 19 ... Read More

Check if a point lies on or inside a rectangle in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 12:57:09

5K+ Views

Suppose we have a rectangle represented by two points bottom-left and top-right corner points. We have to check whether a given point (x, y) is present inside this rectangle or not.So, if the input is like bottom_left = (1, 1), top_right = (8, 5), point = (5, 4), then the ... Read More

Program to Find Out the Smallest Substring Containing a Specific String in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:57:01

1K+ Views

Suppose we have two strings s and t. We have to find the smallest substring in s, where t is also a subsequence of the substring. If that type of substring does not exist, we will return a blank string, and if there are multiple smallest substrings, we will take ... Read More

Program to Find Out Median of an Integer Array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:55:00

178 Views

Suppose we have to implement a class named MedianClass which contains the following methods −add(value) which adds a value to the data structure.median() finds the median of all the numbers currently present in the data structure.So, if we add 5, 3, 8 and find median, the output will be 5.0, ... Read More

Program to Find Out Integers Less than n Containing Multiple Similar Digits in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:29:16

125 Views

Suppose we have an integer n, we have to find the number of positive integers that are less than or equal to n, where the integer numbers at least have a digit occurring more than once.So, if the input is like n = 200, then the output will be 38To ... Read More

Program to Reverse a Substring Enclosed Within Brackets in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:27:50

375 Views

Suppose, we have a lowercase string s that contains letters and parentheses "(" and ")". We have to reverse every string enclosed within parentheses in a recursive manner and return the resultant string.So, if the input is like s = "back(aps)ce", then the output will be “backspace”.To solve this, we ... Read More

Program to Find Out the Number of Moves to Reach the Finish Line in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:26:06

136 Views

Suppose, we have a car and are driving it on a one−dimensional road. Currently we are at position = 0 and with speed = 1. We can perform any of these two operations.Acceleration: position := position + speed and speed := speed * 2 Reverse Gear: speed := −1 when ... Read More

Program to Find Out the Probability of Having n or Fewer Points in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:24:25

54 Views

Suppose we are playing a unique game and we have three values n, k, and h. We start from 0 points, then we can select a number randomly between 1 and h (inclusive) and we will get that many points. We stop when we have scored a minimum of k ... Read More

Program to Find Out a Sequence with Equivalent Frequencies in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:22:21

114 Views

Suppose we have a list of numbers. We have to find the length of the longest sequence of numbers such that when we delete a number from the sequence, each number occurs the same number of times.So, if the input is like numbers = [2, 4, 4, 7, 7, 6, ... Read More

Advertisements