Minimum Number of Adjacent Swaps to Reverse a String

Prabhdeep Singh
Updated on 26-Jul-2023 10:42:32

800 Views

A string str is given and we can swap only adjacent characters to make the string reverse. We have to find the number of minimum moves required to make the string reverse just by swapping the adjacent characters. We will implement two approaches to find the required solution with the explanation and the implementation of the code. Sample Examples Input1: string str1 = “shkej” Output: 10 Explanation First, we will take the last character to the first position which will take 4 swappings, and then the string will be “jshke”. Then we will move ‘e’ to the second ... Read More

Minimum Count of Prefixes and Suffixes Required to Form a Given String

Prabhdeep Singh
Updated on 26-Jul-2023 10:40:31

376 Views

Prefixes are the substring from the given string that starts from the zeroth index and can go up to length 1 to the size of the string. Similarly, the suffix is the substring of any length 1 to the size of the string and ends at the last index. We will be given two strings and have to create the first string by using any number of prefixes and suffixes of the second string in any way. If it is not possible to create the given string from the given methods then we will return -1. Sample Examples Input 1: ... Read More

Encrypt the String

Prabhdeep Singh
Updated on 26-Jul-2023 10:29:46

2K+ Views

Encryption is the technique to change the data by using some techniques or certain steps so it changes to another information or the previous information cannot be gathered from it directly. For encryption, we have to follow certain steps that are fixed for a particular type of encryption. In this problem, we will be given a string and we have to encrypt it by following the given steps − First, we have to get all the substring that contains the same characters and replace that substring with a single character followed by the length of the substring. Now, change ... Read More

Count of 3-Length Strings Using Given Characters with At Least 2 Different Characters

Prabhdeep Singh
Updated on 26-Jul-2023 10:27:26

173 Views

Three integers are given to us ‘a’, ‘b’, and ‘c’ represents the frequency of the three different characters ‘A’, ‘B’, and ‘C’. We have to find the number of different strings that can be formed by using these characters and there must be at least two different characters present in the string formed. We will see two approaches for this problem one is the naive approach and another is the mathematical approach. Sample Examples Input 1: a = 3, b = 2, c = 4 Output: 3 Explanation We can create three strings ‘ABC’, ‘ABC’, ... Read More

Maximize 0s to be Flipped in a Given Binary Array

Prabhdeep Singh
Updated on 26-Jul-2023 10:11:07

160 Views

A Binary Array is a special type of array that only contains the numbers 0 and 1. In this problem, we have given a binary array and integer K. Our task is to count the maximum number of 0’s that can be flipped to 1 in a given binary array such that there are at least K 0’s between two 1s. Sample Examples Input 1: arr[] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, K = 2 Output 1: yes Explanation The 3rd and 6th indexes of the above ... Read More

Print All Balanced Bracket Strings with Wildcards

Prabhdeep Singh
Updated on 26-Jul-2023 10:08:53

223 Views

Balanced Brackets mean if we have a string of brackets then each open bracket has a corresponding close bracket and the pair of brackets is properly nested. The size of the string should be ab even number. In this problem we have given a string of the brackets that also contain the character ‘?’ and our task is to form every possible balanced bracket string by replacing the ‘?’ to appropriate brackets. In our given string only parentheses ‘(‘ and ‘)’ brackets are used. Sample Examples Input 1: str = “()(?)?” Output 1: ()(()) Explanation Only one balanced ... Read More

Check Reachability of End of Binary String by Choosing Jump Value

Prabhdeep Singh
Updated on 26-Jul-2023 10:00:09

90 Views

A binary string is a string that contains only two different types of characters that are 0 and 1. We are given a binary string and two integers L and the R. We can make the jump of size between ‘L’ and ‘R’ length both inclusive and only from the index where the value of the string is ‘0’. We have to start from the Zeroth index and find out whether we can reach the last index or not. Sample Examples Input1: string str = “01001110010” int L = 2, R = 4 Output: Yes, we can reach the ... Read More

Insert Numbers or Rows for Missing Sequential Number in Excel

Namita Aggarwal
Updated on 25-Jul-2023 21:33:33

2K+ Views

Inserting the number for the missing sequential number in Excel means that the user wants to complete the missing number in Excel by using the available Excel feature. This article will understand two basic ways to perform this task. The first example, guide the proper way to use VBA code to complete the missing sequence numbers in Excel. This example can be a little tedious as here, users need to learn the way to code and use proper code indentation to solve the task. Another example available in the sheet describes the method to use kutools, to fill up the ... Read More

Highlight Unique and Duplicate Values in Excel Using Conditional Formatting

Namita Aggarwal
Updated on 25-Jul-2023 21:23:59

448 Views

In Excel, conditional formatting is a feature that allows users to apply formatting to cells based on specific conditions or criteria. By using conditional formatting, the user can color, highlight, or format cells dynamically, that depends upon the values, formulas, or rules the user defines. Unique values are the ones that do not have any exact matching value in the Excel sheet. While the duplicate value is the one that has the same values available in the list. This article illustrates two common examples of the same. The first example allows the user to determine the duplicate value. In this ... Read More

Highlight Top N Values in Excel using Conditional Formatting

Namita Aggarwal
Updated on 25-Jul-2023 19:08:13

288 Views

In Excel, conditional formatting is a feature that allows users to apply formatting to cells based on specific conditions or criteria. By using conditional formatting, the user can color, highlight, or format cells dynamically, that depends upon the values, formulas, or rules the user defines. This feature is useful for some data points, patterns, or trends in the Excel worksheets, this makes the data easier to interpret and analyze the data. Instead of manually scanning through cells or applying to format individually. This feature allows the user to automate the process and apply formatting dynamically as the data changes. Benefits ... Read More

Advertisements