Found 7346 Articles for C++

Count of distinct possible strings after performing given operations

Sakshi Koshta
Updated on 31-Jul-2023 15:24:21

571 Views

Determining the number of unique strings that can be­ obtained by performing a set of give­n operations on a string is a common challenge in compute­r science and mathematics. Se­veral operations, including character de­letion, swapping, or string reversal, can be­ carried out on the string. The obje­ctive is to calculate the total count of diffe­rent output strings achievable through the­se operations irrespe­ctive of their order. The­ problem-solving techniques applie­d for this task comprise dynamic programming, recursion, and combinatorics among others—de­pending upon the nature of spe­cific operations undertaken. Methods To count the distinct possible strings after performing given operations, one ... Read More

Check if there exists a permutation of given string which does not contain any monotonous substring

Sakshi Koshta
Updated on 31-Jul-2023 14:56:56

128 Views

A monotonous substring is a contiguous substring of given string containing characters whose values are all strictly increasing or strictly decreasing. A monotonous substring is a string sequence that either strictly increases or strictly decreases in value. Method Dynamic Programming Backtracking Method 1: Dynamic Programming One technique is to apply dynamic programming to construct table of sub problems, here each item (i, j) in table denotes whether there exists a permutation of the substring S[i...j] that does not contain any monotonous substring. When i=j, the substring comprises only one character and is hence trivially monotonous. ... Read More

Split a binary string into K subsets minimizing sum of products of occurrences of 0 and 1

Sakshi Koshta
Updated on 31-Jul-2023 14:04:28

87 Views

A binary string is made up of a succession of binary numbers, also known as bits, that are either 0 or 1. It is a method of encoding data that uses only two numbers for computer applications where data is stored and processed using electronic circuits that can only recognise two states. In computer programming, binary strings are frequently used to represent data in way that is simple for electronic circuits to handle, such as numbers, text, and images. Method Method 1. Dynamic Programming Method 2. Greedy Approach Method 1: Dynamic Programming To tackle this difficulty, we can employ ... Read More

How to validate Indian Passport number using Regular Expression?

Sakshi Koshta
Updated on 31-Jul-2023 15:28:56

4K+ Views

An Indian passport number is special alphanumeric code that Indian government issues to owner of an Indian passport. The passport number is made up of 8–12 characters, that may include both letters and digits. The first two characters of passport number indicate type of passport, such as P for an ordinary passport, D for a diplomatic passport, and S for an official passport. The next two characters stand for the code of the organization that issues passports, and they are followed by string of numbers that serve as passport holder's special identification. Indian passport numbers are normally printed on the ... Read More

Check if a given string can be formed using characters of adjacent cells of a matrix

Sakshi Koshta
Updated on 31-Jul-2023 13:35:20

105 Views

Let's first understand the meaning of neighbour cells in matrices. To determine how each component fits into your two-dimensional matrix structure visualize each enclosed unit as being encompassed by almost eight adjacent elements positioned across/from them both diagonal directions in addition to vertical/horizontal ones. An example observation can be made about lattice size - the smallest circular enclosure in this design has nine components.(from left-to-right & up-to-down)Cell [row=9, col=8] -- within reach from [row=8, col=7], ...[row=10, col=8], and so forth. This intricate connection network links these adjacent components where they share edges or corners; creating a well-defined matrix structure stepping ... Read More

The camel case character present in a given string

Thanweera Nourin A V
Updated on 28-Jul-2023 15:54:09

507 Views

The aim of this article is to implement a program to print the number of camel case character present in a given string. As you all know, a string is a collection of characters. Now let us see what camel case letters are. Programming languages like Java utilise a naming style called camel case. That is, It includes entering multi-word identities without spaces or underscores, having the initial word in lowercase with successive words in uppercase. Code written in this manner is easier to read and understand. The inner uppercase letters, which resemble camel humps, are what give the name ... Read More

Program to perform a letter frequency attack on a monoalphabetic substitution cipher

Thanweera Nourin A V
Updated on 28-Jul-2023 15:52:42

809 Views

The challenge is to display the top five probable plain texts which could be decrypted from the supplied monoalphabetic cypher utilizing the letter frequency attack from a string Str with size K representing the given monoalphabetic cypher. Let us see what exactly is frequency attack. The very foundation for frequency analysis is the certainty that specific letters and letter combinations appear with varied frequencies all through any given section of written language. Additionally, matter-of-factly every sample of that language shares a common pattern in the distribution of letters. To make it more clear, The English alphabet has 26 letters, ... Read More

Minimum steps to determine the subsequence with max 1s based on given conditions

Thanweera Nourin A V
Updated on 10-Aug-2023 15:56:16

57 Views

The aim of this article is to implement a program to find minimum steps to determine the subsequence with max 1s based on given conditions. So as we all know, a one-dimensional array containing characters that is terminated by a null can be used to define a string. Given is a string Str of length K, wherein K is always even, and contains the characters "0, " "1, " and "?" Divide the string to two separate strings, let's call them Str1 and Str2, each of which is going to include the characters at the even values of Str and ... Read More

Minimize count of repositioning of characters to make all given Strings equal

Thanweera Nourin A V
Updated on 10-Aug-2023 15:48:22

57 Views

The aim here is to determine whether it would be feasible to make all of the strings identical in any amount of operations provided an array Str of strings with size n. Any element can be taken out of the string and put back in at any point in the same or another string all in one action. Return "Yes" if the strings are able to be made to equal one another, and "No" if not, along with the fewest number of operations necessary. Problem Statement Implement a program to minimize count of repositioning of characters to make all given ... Read More

Maximum sum of lengths of a pair of strings with no common characters from a given array

Thanweera Nourin A V
Updated on 28-Jul-2023 17:00:24

133 Views

The aim of this article is to implement a program to maximize the sum of lengths of a pair of strings with no common characters from a given array. By definition, a string is a collection of characters. Problem Statement Implement a program to maximize the sum of lengths of a pair of strings with no common characters from a given array. Sample Example 1 Let us consider the Input array: a[] = [“efgh”, “hat”, “fto”, “car”, “wxyz”, “fan”] Output obtained: 8 Explanation There are no characters in the strings "abcd" and "wxyz" in common. As a ... Read More

Advertisements