- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 34469 Articles for Programming
49 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
54 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
44 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
67 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
110 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
8K+ 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
584 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
129 Views
In this problem, we will find the maximum length of the subsequence such that it should contain the contiguous characters, and the frequency difference of all characters won’t differ more than K. We need to find all possible subsequences of the given string and check whether it contains every character continuously and maximum frequency difference to get the output. Problem statement− We have given a string alpha containing the lowercase alphabetical characters. Also, we have given the positive integer K. We need to find the maximum length of the subsequence of the given string such that it follows the below ... Read More
222 Views
In this problem, we will find the binary string of the given length having the same number of ‘01’ and ‘10’ subsequences. The naïve approach to solving the problem is to generate all binary strings of the given length and check whether it contains the same number of ‘10’ and ‘01’ subsequences using the dynamic programming technique. Another efficient approach is to prepare a binary string based on whether the given length is odd or even. Problem statement − We have given a positive integer ‘len’ which is greater than 2. The task is to find the binary string ... Read More
197 Views
In this problem, we will find the longest common substring using the binary search and rolling hash algorithm. The binary search is an efficient technique for searching values in the sorted array. Here, we will use it to find the maximum length of the common substring. The rolling hash algorithm is used to calculate the hash value for the string. Also, it calculates the hash value for the next substring from the previous substring’s hash value when we add or remove a character from the previous substring. Problem statement − We have given two strings named the first ... Read More