Data Structure Articles

Page 13 of 164

Find the last remaining Character in the Binary String according to the given conditions

Disha Gupta
Disha Gupta
Updated on 23-Oct-2023 194 Views

A binary string is a string that only has two characters, usually the numbers 0 and 1, and it represents a series of binary digits. Problem Statement Now, in this problem, we are given a binary string comprising zeros and ones. We have two conditions to keep in mind while solving the problem. First, one digit can delete another digit that is a ‘1’ can delete a ‘0’ and vice versa. Secondly, if at any moment the entire string consists of only 0’s and 1’s then the corresponding digit is printed. Here, a binary string will be the input given ...

Read More

Maximum length palindromic substring for every index such that it starts and ends at that index

Siva Sai
Siva Sai
Updated on 23-Oct-2023 263 Views

In this article, we'll delve into a fascinating problem in the realm of string algorithms: how to find the maximum length palindromic substring for every index such that it starts and ends at that index in a string. This problem is an interesting challenge, especially for those interested in mastering the art of string manipulation in various programming languages. A palindrome is a string that reads the same backward as forward. For example, "madam" is a palindrome. The challenge here is to find the longest palindromic substring for every index in a given string, where the substring starts and ends ...

Read More

Maximize value of Binary String in K steps by performing XOR of Substrings

Shubham Vora
Shubham Vora
Updated on 23-Oct-2023 526 Views

In this problem, we will maximize the value of the binary string by performing K XOR operations of substrings of the given binary string. To maximize any binary string, we should maximize the substring starting from the leftmost zero. For example, to maximize the ‘11001’ string, we need to choose another substring in such a way that we can maximize the ‘001’ substring. Problem Statement We have given a binary string named bin_str containing N characters. We have to maximize the value of the binary string in K operations by taking the XOR operation of any two substrings. It ...

Read More

Maximize Time by Replacing ‘_’ in a given 24-Hour Format Time

Aishwarya Mani Tripathi
Aishwarya Mani Tripathi
Updated on 23-Oct-2023 246 Views

Maximizing time by replacing ‘_’ in a given 24-hour format time is a problem that involves calculating the maximum possible time by replacing the missing digits in a given time in a 24-hour format. The task is to find the maximum time possible by replacing the characters ‘’ with any digit. In this tutorial, we will discuss how to solve this problem using the C++ programming language. We will provide a step-by-step explanation of the algorithm used to calculate the maximum possible time, along with the C++ code to implement the algorithm. Additionally, we will include test examples ...

Read More

Maximize sum by picking Array element to left of each ‘1’ of a Binary String

Shubham Vora
Shubham Vora
Updated on 23-Oct-2023 161 Views

In this problem, we will find the maximum sum of array elements by picking up unselected elements at the left from the current 1's index. We can use the vector list and sort() method to solve the problem or priority queue. The priority queue inserts the element in the sorted order. Problem Statement We have given a binary string alpha and arr[] of the same length. We need to pick all '1' of alpha one by one and take the maximum element which is not picked from the subarray of arr[] formed using 0 to p elements. Here, ...

Read More

Maximize count of 3-length palindromic subsequences with each index part of a single subsequence

Siva Sai
Siva Sai
Updated on 23-Oct-2023 260 Views

In this article, we are going to delve into an interesting problem related to string manipulation and dynamic programming in various programming languages. The problem we're discussing today is "Maximize the count of 3-length palindromic subsequences with each index part of a single subsequence". Problem Statement Given a string, the task is to find the maximum count of 3-length palindromic subsequences such that each index in the string is a part of a single subsequence. A 3-length palindromic subsequence is a subsequence of the form "aba", where 'a' and 'b' are any characters. Solution Approach To solve this problem, we'll ...

Read More

Maximize “10” Subsequences by replacing at most one 0 with 1

Shubham Vora
Shubham Vora
Updated on 23-Oct-2023 242 Views

In this problem, we need to maximize the ‘10’ subsequences in the given binary string by replacing the 0 or 1 ‘0’ character with ‘1’. We can replace each ‘0’ with ‘1’ one after another and find a maximum number of ‘10’ subsequences in the updated string. Problem statement − We have given a binary string named str1 containing only 0 and 1 characters. We can replace at most one ‘0’ with ‘1’ and need to find the maximum number of ‘10’ subsequences in the given string. Sample Examples Input  str1 = "10110" Output  4 Explanation The ‘10110’ ...

Read More

Make all Strings palindrome by swapping characters from adjacent Strings

Shubham Vora
Shubham Vora
Updated on 23-Oct-2023 857 Views

In this problem, we will make all strings of the given array palindromic by swapping the characters of the adjacent string. To solve the problem, we will try to make the character the same at p and str_len - p - 1 index in all strings, and it is only possible if overall characters at pth index and (str_len - p - 1) index is same. Problem statement - We have given an arr containing multiple strings of the same length equal to N. We need to count the minimum number of operations required to make all strings of ...

Read More

Longest substring with no pair of adjacent characters are adjacent English alphabets

Siva Sai
Siva Sai
Updated on 23-Oct-2023 508 Views

In the realm of string manipulation, identifying patterns and extracting meaningful substrings are common tasks. One intriguing problem involves finding the longest substring where no adjacent characters are adjacent English alphabets. In this article, we'll delve into an efficient solution to this problem, along with a clear explanation and an example test case. Problem Statement Given a string of lowercase English alphabets, we need to find the length of the longest substring where no adjacent characters are adjacent English alphabets. For example, in the string "abacabx", the longest substring satisfying this condition is "abx", with a length of 3. Approach ...

Read More

Longest Substring of A that can be changed to Substring of B in at most T cost

Shubham Vora
Shubham Vora
Updated on 23-Oct-2023 297 Views

In this problem, we will find the longest substring of A to convert it to a substring of B starting from the same index in less than T cost. We will use the binary search algorithm to find the maximum length of the substring which follows the given condition. However, the naïve approach to solving the problem is to find all substrings following the conditions in the problem statement and take the substring with maximum length. Problem statement − We have given a string A and B of length N. Also, we have given a total cost, ‘T’. The ...

Read More
Showing 121–130 of 1,635 articles
« Prev 1 11 12 13 14 15 164 Next »
Advertisements