Found 33676 Articles for Programming

Reverse given Range of String for M queries

Shubham Vora
Updated on 17-Jul-2023 16:34:47

339 Views

In this problem, we will perform M reverse queries on the given string according to the array values. The naïve approach to solving the problem is to reverse each string segment according to the given array value. The optimized approach uses the logic that when we reverse the same substring two times, we get the original string. Problem statement − We have given an alpha string containing the alphabetical characters. Also, we have given an arr[] array of size M containing the positive integers. We need to perform the M operations on the given string and return the final ... Read More

How to Set Axis Limits bokeh?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 16:49:05

405 Views

Bokeh is a built-in Python library that makes a highly interactive graph for data visualization. Generally, web developers use this library to build powerful dashboards, live app applications, and, simple charts on the web. In Python, we have some bokeh built-in functions like figure(), vbar(), y_range(), etc. to Set Axis Limits bokeh. The various field used this library such as Data Scientists, Data Engineers, and, Web Developers. Syntax The following syntax is used in the examples − figure() The figure is a built-in method of bokeh library and it is known for a subclass of plot that simply create ... Read More

Parity of Count of Letters whose Position and Frequency have Same Parity

Shubham Vora
Updated on 17-Jul-2023 16:32:47

217 Views

In this problem, we will count the number of characters whose frequency and position have the same parity and print the count of the number as odd or even. To solve the problem, we can find the frequency of each character in the string, and count total characters whose freqeuncy and position have the same parity. After that, we can print the odd or even answer based on the counts. Problem statement − We have given a string alpha containing only lowercase english alphabetical characters. We need to check whether the number of characters having equal parity of their alphabetical ... Read More

Minimize Removal from Front or End to Make the Binary String at Equilibrium

Shubham Vora
Updated on 17-Jul-2023 16:26:57

135 Views

In this problem, we will print the minimum number of characters that we need to remove from the start and end to make the count of ‘1’ and ‘0’ the same in the given string. If we find the largest substring with an equal number of ‘1’ and ‘0’, we can get the answer by subtracting the substring length from the given string’s length. We will use the prefix sum technique to find the largest substring having an equal number of ‘1’ and ‘0’. Problem statement − We have given the ‘bin_str’ binary string containing the N characters. We ... Read More

Minimize Max Frequency Difference of 0 & 1 by Dividing Binary String into K Disjoint Subsequence

Shubham Vora
Updated on 17-Jul-2023 16:25:19

126 Views

In this problem, we will divide the given binary string into the K subsequences such that we can minimize the maximum absolute difference of count of ‘1’ and ‘0’ in the given string. The logic to solve the problem is to create a maximum pair of 0 and 1 in subsequences. So, we can get the minimum difference between each subsequence. Problem statement − We have given a bin_str binary string of length N. We have also given the positive integer K. We need to divide the given string into the K disjoint subsequences to minimize the maximum absolute ... Read More

Maximum Product of First and Last Character of String after Rotation

Shubham Vora
Updated on 17-Jul-2023 16:22:35

110 Views

In this problem, we will find the maximum possible product of the first and last digits of the string by rotating the string multiple times. The naïve approach is that find all rotations of the string, take the product of the first and last character, and choose the maximum product as an answer. Another approach is to find the product of every adjacent pair of characters and choose the maximum product. Problem statement − We have given a string num containing the numeric digits. We need to find the maximum product of the first and last character of the given ... Read More

Make Binary Strings Equal by Replacing 2nd Bit Repeatedly

Shubham Vora
Updated on 17-Jul-2023 16:19:04

149 Views

In this problem, we need to convert the bin1 string to the bin2 string by replacing the second character of the bin1 string with the minimum or maximum of the first and second characters and removing the first character. As we need to remove the initial character, we need to ensure that the last len2 − 1 character are the same in both strings. Also, we need to ensure that we can get the first character of the second string by performing the given operation with the starting characters of the bin1 string. Problem statement − We have given bin1 ... Read More

Longest Substring of given Characters by Replacing at Most K Characters for Q Queries

Shubham Vora
Updated on 17-Jul-2023 16:14:29

224 Views

In this problem, we have given M queries, and after performing each query on the given string, we need to print the maximum length of the string having only the ‘ch’ character. We will use the tabulation method of dynamic programming to find the maximum possible length of the substring after replacing the at most K characters with the given character. Problem statement − We have given a string alpha of length N and que[] array containing M queries of type {K, ch}, where K is a positive integer, and ch is a character. It is given that for each ... Read More

How to set axes labels & limits in a Seaborn plot?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 16:46:23

12K+ Views

Creating the plots using Seaborn will adjust the labels and axes limitations to make the plots more understandable. The axes labels are the names we can provide to the x and y axes so that others can understand what the plots show. We can focus on select areas of the data that are significant by altering the axes' limitations. Seaborn includes straightforward methods for setting axis labels and boundaries that allow us to make our plots more informative. In Python, we have some built-in functions like xlabel(), ylabel(), xlim(), and, ylim() that can be used to set the axes labels ... Read More

How to set the tab size in Text widget in Tkinter?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 16:44:39

953 Views

The Python Tkinter module allows us to develop graphical user interfaces (GUIs) and show main windows on the screen. The value of a Tkinter window screen from its ability to improve the user experience and enable the interactivity of user's programs. In Python, we have some built-in functions like Tk(), Text(), pack(), etc. that can be used to set the tab size in Text widget in tkinter. Syntax The following syntax is used in the examples − Tk() This is a built-in function of tkinter module that helps to display the main window and manage all the components of ... Read More

Advertisements