Shubham Vora has Published 962 Articles

How to set Parent State from Children Component in ReactJS?

Shubham Vora

Shubham Vora

Updated on 26-Oct-2023 02:29:41

30K+ Views

In ReactJS, we can set the state in the child component by passing the values as a prop of the child component. Sometimes, we require to set the state from the children component to the parent component in ReactJS. We can create a state handler function in the parent component ... Read More

Minimize operations to make String palindrome by incrementing prefix by 1

Shubham Vora

Shubham Vora

Updated on 23-Oct-2023 16:10:04

85 Views

In this problem, we will count the number of operations required by increasing the prefix characters of the given string. We will use character difference to count the minimum number of operations required to make string palindromic. Problem Statement We have given a string nums containing the numeric ... Read More

Maximum moves to reach destination character in a cyclic String

Shubham Vora

Shubham Vora

Updated on 23-Oct-2023 15:59:58

58 Views

In this problem, we will find the maximum distance from the initial to the final character in the cyclic string. The basic approach to solve the problem is to find the next closest final character for every initial character and update the maximum distance if required. Another approach traverses the ... Read More

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

Shubham Vora

Shubham Vora

Updated on 23-Oct-2023 15:11:47

152 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 ... 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 15:03:43

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

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

Shubham Vora

Shubham Vora

Updated on 23-Oct-2023 14:57:07

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

Make all Strings palindrome by swapping characters from adjacent Strings

Shubham Vora

Shubham Vora

Updated on 23-Oct-2023 14:54:49

300 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 ... 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 14:34:21

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

Find two unique Palindrome Strings using given String characters

Shubham Vora

Shubham Vora

Updated on 20-Oct-2023 15:00:47

77 Views

In this problem, we will construct two palindromic strings using the given string’s characters. We can use the character’s frequency to solve the problem. We can construct two new palindromic strings only if both characters’ frequencies are even or if any characters have an even frequency and others have an ... Read More

Find Strings formed by replacing prefixes of given String with given characters

Shubham Vora

Shubham Vora

Updated on 20-Oct-2023 14:45:29

57 Views

In this problem, we will form a triangle from the given string. The triangle will contain the rows equal to the string length - 1, and in each row, we replace the starting characters equal to the row number with '.' Character. We can use the loop to form ... Read More

Advertisements