Shubham Vora has Published 957 Articles

Check If a String Can Be Made Palindromic By Swapping Pairs Of Characters From Indices Having Unequal Characters In a Binary String

Shubham Vora

Shubham Vora

Updated on 18-Jul-2023 16:17:27

343 Views

Problem Statement We have given string str and a binary string B. The length of both strings is equal to the N. We need to check if we can make string str palindromic by swapping the characters of it multiple times at any pair of indices that contains unequal ... Read More

Create a string of specific length in C++

Shubham Vora

Shubham Vora

Updated on 18-Jul-2023 16:11:27

8K+ Views

In C++, the string is a collection of various alphanumeric and special characters. We can create a string using the ‘string’ data type in C++. Problem Statement We have given a length of the string and one single character, and we require to generate a string of a given ... Read More

Check if uppercase characters in a string are used correctly or not

Shubham Vora

Shubham Vora

Updated on 18-Jul-2023 16:08:57

280 Views

Problem Statement We have given a string ‘str’, containing the alphabetical characters in uppercase or lowercase. We require to check if uppercase characters are used correctly in the string. Followings are the correct way to use uppercase characters in the string. If only the first character is in uppercase, ... Read More

Sort an Array of Strings in Lexicographical Order

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 16:36:54

1K+ Views

In this problem, we will sort the array of strings in the lexicographical order. There are various sorting algorithms to sort the array of strings. In this tutorial, we will use the built−in sort() method to sort the strings. Also, we will use the merge sort algorithm, one of ... Read More

Reverse given Range of String for M queries

Shubham Vora

Shubham Vora

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

337 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 ... Read More

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

Shubham Vora

Shubham Vora

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

215 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 ... Read More

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

Shubham Vora

Shubham Vora

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

134 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’, ... Read More

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

Shubham Vora

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 ... Read More

Maximum Product of First and Last Character of String after Rotation

Shubham Vora

Shubham Vora

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

107 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 ... Read More

Make Binary Strings Equal by Replacing 2nd Bit Repeatedly

Shubham Vora

Shubham Vora

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

148 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 ... Read More

Advertisements