Found 1860 Articles for Data Structure

Program to convert given Binary to its equivalent ASCII character string

Shubham Vora
Updated on 25-Aug-2023 15:53:18

565 Views

In this problem, we need to convert the binary string to the character string. We can convert the binary string to an ASCII number string first, and then we can convert the character string. Problem statement – We have given a binary string bin_str whose size is multiple of 8. We need to convert the binary string to the character string. Sample examples Input bin_str = "0110110001101010" Output 'lj' Explanation – The ‘01101100’ is equivalent to 108 in the decimal, which is equivalent to the ASCII value of the ‘l’. The ‘01101010’ equals 106, and ... Read More

Minimum Number of Insertions in given String to Remove Adjacent Duplicates

Shubham Vora
Updated on 25-Aug-2023 15:49:58

118 Views

In this problem, we will count the minimum number of characters we need to insert to remove all adjacent duplicate characters. To solve the problem, we need to count the total number of adjacent duplicate character pairs. Problem statement – We have given a string named str containing N alphabetical characters. We need to find the total number of different characters we require to add to the string such that the resultant string shouldn’t contain any adjacent duplicated characters. Sample examples Input str = "ccddrt" Output 2 Explanation – We need to insert one character ... Read More

Minimum Jumps from Either End to Reach Largest and Smallest Character in given String

Shubham Vora
Updated on 25-Aug-2023 15:43:26

153 Views

In this problem, we require to find the minimum jumps required to make to reach the largest and smallest character in the given string. We can move to the next or previous character in one jump. We can solve the problem by finding the position of the lexicographically largest and smallest character in the given string. After that, we can find the minimum jumps required to the found indexes from the left and right sides. Problem statement – We have a string str of length N containing the alphabetical characters in the uppercase. We need to find the minimum number ... Read More

Length of Smallest Substring to be Replaced to make Frequency of each Character as N/3

Shubham Vora
Updated on 25-Aug-2023 15:38:41

154 Views

In this problem, we need to find the smallest substring so that we can replace its character and make the frequency of each character equal to the N/3 in the given string. We can use the sliding window technique to solve the problem. We can find the minimum window size, which contains all excess characters, that will be the answer to the problem. Problem statement – We have given a string alpha. The size of the alpha is N which is always divisible by 3. The given task is to find the minimum length of the substring so that we ... Read More

Javascript Program to Minimize Characters to be Changed to make the Left and Right Rotation of a String Same

Shubham Vora
Updated on 25-Aug-2023 15:31:37

117 Views

In this problem, we require to determine the minimal cost to make the string’s left and right rotation same. Here is the observation which we will use to solve the problem. All characters should be equal for strings with odd lengths to make the left and right rotations the same. The string with an even length should have characters same at the even and odd indexes. Problem statement – We have a string of size N containing the different characters. We need to determine the minimum cost to make the left and right rotations of the given ... Read More

Java Program to Minimize Characters to be changed to make the Left and Right Rotation of a String Same

Shubham Vora
Updated on 25-Aug-2023 15:24:18

137 Views

In this problem, we need to change the minimum characters in the given string to make its left and right rotations the same. In the string, we can observe that we can only make the left and right rotations of the string same if the string has an odd length and all characters are same, or the string has an even length and characters at even and odd indexes the same. For example, abab – Left and right rotation of the string is baba and baba. aaa – Left and right rotation of the stirng is aaa and aaa. ... Read More

Java Program to Find Maximum number of 0s placed consecutively at the start and end in any rotation of a Binary String

Shubham Vora
Updated on 25-Aug-2023 15:22:27

218 Views

In this problem, we will write Java code to find the maximum sum of consecutive zeros at the start and end of any string rotation. First, we will use a naïve approach to solve the problem, which generates all rotations of the binary string and counts the starting and ending consecutive zeros. After that, we will learn an optimized algorithm that counts the maximum consecutive zeros. Problem statement – Here, we have a string of size N containing only 0 and 1 characters. We need to find the maximum sum of consecutive zeros at the start and end of any ... Read More

Java Program to Implement Unrolled Linked List

Shubham Vora
Updated on 24-Aug-2023 18:10:04

218 Views

In this problem, we will learn to implement the unrolled linked list. The unrolled linked list is a specialized version of the linked list. The normal linked list contains a single element in a single node, but the unrolled linked list contains a group of elements in each node. Also, insertion, deletion, and traversal in the unrolled linked list work the same as the typical linked list. The linear search is faster in the array than in the linked list. So, we can add elements in the array and an array in each node of the linked list. Also, ... Read More

Java Program to Implement the Vizing's Theorem

Shubham Vora
Updated on 24-Aug-2023 18:07:17

137 Views

In this problem, we need to implement Vizing's Theorem. Vizing's Theorem is used with graphs. Theorem statement - For any undirected graph G, the value of the Chromatic index is equal to the d or d + 1, where d is the maximum degree of the graph. The degree for any vertex is the total number of incoming or outgoing edges. Problem statement - We have given a graph and need to implement Vizing's Theorem to find the Chromatic index of the graph. Note - The chromatic index is a positive integer, requiring a ... Read More

Java Program to Implement the Schonhage-Strassen Algorithm for Multiplication of Two Numbers

Shubham Vora
Updated on 24-Aug-2023 18:04:22

257 Views

The Schonhage-Strassen algorithm is useful when we need to multiply large decimal numbers. As Java supports the 1018 size of integers, and if we need to multiply the digits of more than 1018, we need to use the Schonhage-Strassen algorithm, as it is one of the fastest multiplication algorithms. It uses the basic rules for the multiplication of two numbers. It first performs the linear convolution and then performs the carry to get the final result. Problem statement - We have given mul1 and mul2 large decimal numbers and need to implement the Schonhage-Strassen algorithm to multiply both ... Read More

Advertisements