Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 180 of 377

Array element moved by k using single moves?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 151 Views

This problem involves simulating a badminton tournament where players compete until someone wins K consecutive matches. We have an array representing the queue of players, and we need to find who becomes the ultimate winner. Syntax int winner(int arr[], int n, int k); Algorithm The key insight is that we don't need to simulate every match. Instead, we can observe that − If K >= n-1, the largest element will always win Otherwise, we track the best player encountered and count consecutive wins Begin if k ...

Read More

Arrangement of words without changing the relative position of vowel and consonants?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 212 Views

In this problem, we need to find the number of ways to arrange letters in a string while maintaining the relative positions of vowels and consonants. This means vowels stay in vowel positions and consonants stay in consonant positions. The approach involves counting vowels and consonants separately, calculating permutations for each group considering duplicate letters, then multiplying the results. Syntax long long arrangeWayCount(char str[]); Algorithm arrangeWayCount(str) Begin define an array 'freq' to store frequency. count and place frequency of each characters in freq array. such ...

Read More

Arrange first N natural numbers such that absolute difference between all adjacent elements > 1?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 461 Views

We need to arrange the first N natural numbers such that the absolute difference between every two consecutive elements is greater than 1. If no such permutation exists, we return -1. The approach uses a greedy strategy − arrange all odd numbers in descending order, followed by all even numbers in descending order. This ensures adjacent elements always differ by at least 2. Syntax void arrangeN(int N); Algorithm Begin if N is 1, then return 1 if N is 2 or 3, then return -1 as no such ...

Read More

Area of Reuleaux Triangle?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 590 Views

A Reuleaux Triangle is a special geometric shape formed by the intersection of three circles. It is constructed using an equilateral triangle as a base, where each side of the triangle becomes the radius of a circle centered at the opposite vertex. The area calculation involves three circular sectors minus the overlapping equilateral triangle areas. ...

Read More

Area of a n-sided regular polygon with given Radius?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 318 Views

Here we will see how to get the area of an n-sided regular polygon whose radius is given. Here the radius is the distance from the center to any vertex. To solve this problem, we draw a perpendicular from the center to one side. Let each side have length 'a'. The perpendicular divides the side into two equal parts, each of length a/2. The perpendicular and the radius form an angle x, and let the radius length be r. ...

Read More

Area of a leaf inside a square?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 1K+ Views

Here we will see how to calculate the area of a leaf-shaped region inside a square ABCD, where each side of the square has length 'a'. A B C D Center a The leaf consists of two equal circular segments. Each segment is formed by the intersection of ...

Read More

Area of a circle inscribed in a rectangle which is inscribed in a semicircle?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 220 Views

Let us consider a semicircle with radius R. A rectangle of length l and breadth b is inscribed in that semicircle. Now a circle with radius r is inscribed in the rectangle. We need to find the area of the inner circle. R l b r ...

Read More

Arc length from given Angle?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 233 Views

Here we will see how to calculate the arc length from a given angle. When a circle with radius r is given and we know the angle x in degrees, we can find the arc length using a simple formula. r L x° Here r is the radius and x is the angle in degrees. We need to find the value of L (arc length). The formula is − Syntax L = ...

Read More

An interesting solution to get all prime numbers smaller than n?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 223 Views

Here we will see how to generate all prime numbers that are less than n using Wilson's theorem. According to Wilson's theorem, if a number k is prime, then ((k - 1)! + 1) mod k will be 0. This approach provides a mathematical foundation for prime detection. Note: This method is primarily of theoretical interest because factorial calculations grow extremely large, making it impractical for larger values of n in standard programming languages. Syntax void genAllPrimes(int n); // Generates all prime numbers less than n using Wilson's theorem Algorithm Begin ...

Read More

An Interesting Method to Generate Binary Numbers from 1 to n?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 574 Views

Here we will see one interesting method for generating binary numbers from 1 to n. This approach uses a queue data structure to generate binary representations in sequence. Initially the queue holds the first binary number '1'. We repeatedly remove elements from the queue, print them, then append '0' and '1' to create the next binary numbers and insert them back into the queue. Algorithm genBinaryNumbers(n) Begin define empty queue insert "1" into the queue while n is not 0, do delete ...

Read More
Showing 1791–1800 of 3,768 articles
« Prev 1 178 179 180 181 182 377 Next »
Advertisements