Found 33676 Articles for Programming

Longest Subsequence with Same Char as Substrings and Difference of Frequency at Most K

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

260 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

Generate Binary String with equal number of 01 and 10 Subsequence

Shubham Vora
Updated on 17-Jul-2023 16:06:05

428 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

Find the Longest Common Substring using Binary search and Rolling Hash

Farhan Muhamed
Updated on 06-Aug-2025 18:37:49

469 Views

In this article, we will explain the concept of rolling hash and find the longest common substring using binary search and rolling hash. We will also provide a C++ code implementation for the same. Rolling Hash of a String Problem Statement Algorithm to Find the Longest Common Substring C++ Code Implementation Time and Space Complexity Rolling Hash of a String Rolling hash is a cryptographic technique used to calculate the hash value of a string. In this, we ... Read More

How to setup Conda environment with Jupyter Notebook?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 16:42:10

447 Views

The Jupyter Notebook is an open-source web application that allows users to run all features of the Data and Machine Learning project. The word Conda is known as package manager which handles different packages by installing them through its command. The Conda environment is similar to Python virtual environment that allows users to write code in Python programming language. The benefits of a conda environment − Getting more Python Package that handles large-scale data project. Its packages help to understand the complex structure of any dataset. System Requirement to set up Conda Environment With Jupyter Notebook ... Read More

Find Characters Which When Increased by K are Present in String

Shubham Vora
Updated on 17-Jul-2023 16:01:01

97 Views

In this problem, we will find all unique characters of the string with their first index, which is present in the string, after incrementing all characters of the given string by K. For a problem solution, we can take each unique character of the given string. Next, we can update each character individually and check whether the updated character is present in the string and not updated to another character to get the answer. Problem statement − We have given a string alpha and positive integer K. We need to increment each character’s ASCII value of the given string by ... Read More

Find all Words from String Present after Given N Words

Shubham Vora
Updated on 17-Jul-2023 12:54:21

180 Views

In this problem, we will find each word of the string which comes after all words of the ‘words’ array. The first approach to solve the problem is to split the string into words and match elements of the words[] array with the string words. If we find words[] array’s element in the same order inside the string, we print the next word of the string. Another approach is to create a string of all elements of the words[] array. After that, we can find that string as a substring in the alpha string. If we find it as a ... Read More

Find a Number Such that Sum of N with it is a Palindrome

Shubham Vora
Updated on 17-Jul-2023 12:46:17

220 Views

In this problem, we will find the string of length equal to the given string so that when we sum both strings, we get the palindromic strings. Here, we can find another string such that the sum of both becomes 99999…, the largest palindromic string of the same length. If the given string starts with the ‘9’, we can find another string such that the sum of both becomes ‘11111…’. Problem statement – We have given a num string containing the numeric digits. We need to find the numeric string of the same length without leading zeros so that ... Read More

Get Random Range Average using Python

Rohan Singh
Updated on 17-Jul-2023 17:12:22

789 Views

Python provides a robust set of tools and libraries to generate random numbers within a specific range and calculate their average. We can use the Numpy library, statistics module, random module, and random.choice function etc to Randomly generate numbers within a range and find their average. In this article, we will use these methods to generate random numbers and find their average. Algorithm A general algorithm to generate random numbers and find the average using Python is as follows: Generate random numbers within a range Store these numbers in a list or array. Calculate the average of the ... Read More

Count ways to Split String into K Substrings Starting with Even Digit and Min Length M

Shubham Vora
Updated on 17-Jul-2023 12:42:49

354 Views

In this problem, we will count ways to partition the given string into the K substrings such that it follows the condition given in the problem statement. We will use the recursion to solve the problem. Also, we will use the tabular dynamic programming approach to solve the problem efficiently. Problem statement − We have given a string named bin_Str of a particular length. The string contains only numeric digits from ‘0’ to ‘9’. We need to count the number of ways to partition the string in K substrings such that it follows the below condition. The substring should ... Read More

How to set alignment of each dropdown widget in Jupyter?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 16:40:20

549 Views

We will use HTML and CSS to align dropdown widgets in Jupyter. We may modify the alignment of the dropdown widget by adding certain CSS classes to it. This allows us to place the dropdowns in our Jupyter notebook either side by side or one below the other, making it seem visually attractive. Here is a simple method to help us align dropdown widgets in Jupyter and improve the user experience. The following syntax is used in the examples − Dropdown() The Dropdown() is a built-in function that follows the module named ipywidgets and it builds the list ... Read More

Advertisements