Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 63 of 377

Course Schedule IV in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 342 Views

Suppose there are a total of n courses we can to take, the courses are labeled from 0 to n-1.Some courses may have direct prerequisites, as example, to take course 0 we have first to take course 1, which is expressed as a pair: [1, 0].So, if we have a number of courses n, a list of direct prerequisite pairs and a list of queries pairs.You should find the answer for each queries[i] whether the course queries[i][0] is a prerequisite of the course queries[i][1] or not. Finally, we have to return a list of boolean, the answers to the given ...

Read More

Program to generate all possible strings by taking the choices in python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 496 Views

Suppose we have a string s of lowercase alphabet characters, other characters like "[", "|", and "]". Here "[a|b|c]" indicates either "a", "b", or "c" can be chosen as a possibility. We have to find a list of strings containing all possible values that s can represent. Here "[]" cannot be nested and may have any number of choices.So, if the input is like s = "[d|t|l]im[e|s]", then the output will be ['dime', 'dims', 'lime', 'lims', 'time', 'tims']To solve this, we will follow these steps:if s is empty, thenreturn a list with blank stringn := size of sseq := a ...

Read More

Program to find minimum number of hops required to reach end position in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 723 Views

Suppose we have one array nums, where all elements are positive. We are at index 0. Here, each element in the array represents our maximum jump length at that position. Our goal is to reach to the final index (n-1, where n is size of nums) with less number of jumps. So if the array is like [2, 3, 1, 1, 4], and then the output will be 2, as we can jump to index 1 from 0, then jump to index 4, that is the last index.To solve this, we will follow these steps −end := 0, jumps := ...

Read More

Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 254 Views

Suppose we have a rectangular cake with height h and width w, we also have two arrays of integers horizontalCuts and verticalCuts where horizontalCuts[i] represents the distance from the top of the rectangular cake to the ith horizontal cut and similarly, verticalCuts[j] represents distance from the left of the rectangular cake to the jth vertical cut.We have to find the maximum area of a piece of cake after we cut it at each horizontal and vertical position provided in the arrays horizontalCuts and verticalCuts. The answer may be large, so return this modulo 10^9 + 7.So, if the input is ...

Read More

Program to find number of ways we can split a palindrome in python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 400 Views

Suppose we have a string s, we have to find the number of ways we can partition the string such that each part is a palindrome.So, if the input is like s = "xyyx", then the output will be 3, as we have splits like: ["x", "yy", "x"], ["x", "y", "y", "x"], ["xyyx"].To solve this, we will follow these steps:n := size of stable := a list of size n + 1 and fill it with 0table[0] := 1for i in range 0 to n, dofor j in range 0 to i - 1, dosub := s[from index j to ...

Read More

Reorder Routes to Make All Paths Lead to the City Zero in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 556 Views

Suppose there are n different cities those are numbered from 0 to n-1 and there are also n-1 roads such that there is only one way to travel between two different cities. Suppose the ministry of transport decided to orient the roads in one direction because they are too narrow.Here the roads are represented by connections where connections[i] = [a, b] this represents a road from city a to b.If there is a big event in the capital (city numbered as 0), and many people want to travel to this city. We have to perform some reorienting task on some ...

Read More

Program to find number of sublists we can partition so given list is sorted finally in python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 219 Views

Suppose we have a list of numbers called nums. We can partition the list into some individual sublists then sort each piece. We have to find the maximum number of sublists we can partition to such that nums as a whole is sorted afterwards.So, if the input is like nums = [4, 3, 2, 1, 7, 5], then the output will be 2, as we can sort the sublists like [4, 3, 2, 1] and [7, 5]To solve this, we will follow these steps:count := 0main_sum := 0, sorted_sum := 0for each element x from nums and y from sorted ...

Read More

The k Strongest Values in an Array in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 259 Views

Suppose we have an array of numbers called arr and an integer k. There is a value arr[i] that is said to be stronger than a value arr[j] when |arr[i] - m| > |arr[j] - m| where m is the median of the array. If |arr[i] - m| is same as the |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j]. So we have to find a list of the strongest k values in the array.So, if the input is like arr = [1, 2, 3, 4, 5], k = 2, then the ...

Read More

Program to check whether all palindromic substrings are of odd length or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 355 Views

Suppose we have a string s, we have to check whether all its palindromic substrings have odd lengths or not.So, if the input is like s = "level", then the output will be TrueTo solve this, we will follow these steps −for i in range 1 to size of s, doif s[i] is same as s[i - 1], thenreturn Falsereturn TrueLet us see the following implementation to get better understanding −Exampleclass Solution:    def solve(self, s):       for i in range(1, len(s)):          if s[i] == s[i - 1]:             ...

Read More

Campus Bikes II in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 323 Views

Suppose we have a 2D grid, that represents a campus, there are N workers and M bikes, The value of N

Read More
Showing 621–630 of 3,768 articles
« Prev 1 61 62 63 64 65 377 Next »
Advertisements