Articles on Trending Technologies

Technical articles with clear explanations and examples

How to put a title for a curved line in Python Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 738 Views

To add a title to a curved line plot in Python Matplotlib, you use the plt.title() method after creating your plot. This is essential for making your visualizations clear and informative. Steps Set the figure size and adjust the padding between and around the subplots. Create x and y data points such that the line would be a curve. Plot the x and y data points using plt.plot(). Place a title for the curve plot using plt.title() method. Display the figure using ...

Read More

Program to find length of longest sublist containing repeated numbers by k operations in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 385 Views

Suppose we have a list called nums and a value k, now let us consider an operation by which we can update the value of any number in the list. We have to find the length of the longest sublist which contains repeated numbers after performing at most k operations. So, if the input is like nums = [8, 6, 6, 4, 3, 6, 6] k = 2, then the output will be 6, because we can change 4 and 3 to 6, to make this array [8, 6, 6, 6, 6, 6, 6], and the length of sublist ...

Read More

Program to find length of longest contiguous sublist with same first letter words in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 371 Views

Suppose we have a list of lowercase alphabet strings called words. We have to find the length of the longest contiguous sublist where each word has the same first letter. So, if the input is like words = ["she", "sells", "seashells", "on", "the", "sea", "shore"], then the output will be 3, because the longest contiguous sublist is ["she", "sells", "seashells"] where each word starts with 's'. Algorithm To solve this, we will follow these steps − Initialize cnt = 1 to track current sequence length Initialize maxcnt = 0 to track maximum length found Initialize ...

Read More

Matplotlib – How to plot the FFT of signal with correct frequencies on the X-axis?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 3K+ Views

To plot the FFT (Fast Fourier Transform) of a signal with correct frequencies on the X-axis in matplotlib, we need to properly compute the frequency bins and visualize the power spectrum. Understanding FFT Frequency Calculation The key to plotting FFT with correct frequencies is using np.fft.fftfreq() which returns the discrete Fourier Transform sample frequencies. For real signals, we typically plot only the positive frequencies using np.fft.rfftfreq(). Basic FFT Plot with Normalized Frequencies Here's how to create a basic FFT plot with normalized frequencies ? import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] ...

Read More

Program to find number of possible position in n-person line with few person at front and back in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 292 Views

Suppose we have three numbers n, a and b. Consider we are in a line of n people, and we are unaware about our position in the line. But we know there are at least a number of people in front of us and at most b number of people behind us. We have to find the number of possible positions for us. So, if the input is like n = 10, a = 3, b = 4, then the output will be 5. There are 10 people in the line with at least 3 people in front and ...

Read More

Program to find lexicographically largest mountain list in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 429 Views

A mountain list is a sequence that strictly increases to a peak and then strictly decreases. Given three positive numbers n, lower, and upper, we need to find the lexicographically largest mountain list of length n with all values in range [lower, upper]. The challenge is ensuring both increasing and decreasing parts are non-empty while maximizing the lexicographic order. Problem Analysis For a valid mountain list of length n: Must have at least one increasing element and one decreasing element Total possible unique values = upper − lower + 1 Maximum mountain length = 2 ...

Read More

Program to find maximum sum by performing at most k negate operations in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 379 Views

Suppose we have a list of elements called nums and another value k. We can perform an operation where we select an element from nums and negate it. We can perform exactly k number of operations and need to find the maximum resulting sum. So, if the input is like nums = [2, 1, -6, -2] and k = 3, then the output will be 9. If we negate -6 and -2 and 1, we get [2, -1, 6, 2] and its sum is 9. Algorithm To solve this problem, we follow these steps − ...

Read More

Program to find value for which given array expression is maximized in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 353 Views

Suppose we have two arrays called nums and values, both contain integers where the values of nums are strictly increasing and their lengths are the same. We have to find the maximum value of v for a pair of indices i, j such that i ≤ j that maximizes v = values[i] + values[j] + nums[j] - nums[i]. So, if the input is like nums = [1, 2, 7] and values = [-4, 6, 5], then the output will be 16. If we pick i = 1 and j = 2 we get 6 + 5 + 7 - ...

Read More

Program to find number of elements in matrix follows row column criteria in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 812 Views

Suppose we have a binary matrix; we have to find the number of elements in matrix that follows the following rules − matrix[r, c] = 1 matrix[r, j] = 0 for every j when j is not equal to c and matrix[i, c] = 0 for every i when i is not equal to r. In simple terms, we need to find cells that contain 1 and are the only 1 in both their row and column. Example Input So, if the input is like ...

Read More

Program to find k where k elements have value at least k in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 432 Views

Suppose we have a list of numbers called nums, that contains only non-negative numbers. If there are exactly k number of elements in nums that are greater than or equal to k, find the value k. If we cannot find such value, then return -1. So, if the input is like nums = [6, 4, 0, 8, 2, 9], then the output will be 4, because there are exactly 4 elements that are greater than or equal to 4: [6, 4, 8, 9]. Algorithm To solve this, we will follow these steps − ...

Read More
Showing 3201–3210 of 61,299 articles
« Prev 1 319 320 321 322 323 6130 Next »
Advertisements