Found 1862 Articles for Data Structure

Count of strings satisfying the given conditions

Mallika Gupta
Updated on 31-Jul-2023 17:28:44

67 Views

Introduction A string in C++ is also a primitive data type which is comprised of alphanumeric characters. The letters in a string are case sensitive, but strings can contain both upper and lower case. In this article, we are given an input array of lowercase strings, and require the count of the pair of strings from the array satisfying the following conditions − Both the strings should have the same first and last vowel Both the strings have an equal number of pairs An array is a data structure simulating the storage of similar elements. A C++ array ... Read More

Encrypt a string by repeating i-th character i times

Mallika Gupta
Updated on 31-Jul-2023 17:36:26

75 Views

Introduction A C++ string is a fixed sequence of alphanumeric characters. It is a continuous stream of occurring characters, which may be digits, characters or even special symbols. Every string is characterized by a definite length. The positions by which the characters are accessed begin with 0. Strings can contain unique or repeated characters concatenated together. They can be subjected to various manipulations and concatenation operations. In this article, we are going to develop a code that takes as input a string, and displays the encrypted string, wherein the first character is repeated 1 time, the second character is ... Read More

Count of buttons pressed in a keypad mobile

Mallika Gupta
Updated on 31-Jul-2023 17:11:33

129 Views

Introduction A string in C++ is an in-built storage structure used to contain digits, characters or even special symbols. Every string is associated with a definite size, specified by its length attribute. By default, the string positions begin with 0. The characters in string can be subjected to various types of manipulations − New characters can be appended at the end of a string. A character can be appended multiple times to the string. In this article, we are going to develop a code that takes as input a string, and counts the number of times the keys ... Read More

Check if the string contains consecutive letters and each letter occurs exactly once

Mallika Gupta
Updated on 31-Jul-2023 17:07:46

895 Views

Introduction A string in C++ is a sequence of characters, which may be distinct or repetitive in nature. Consecutive characters are the characters occurring simultaneously, with a difference of 1. For instance, the characters a and b are consecutive, since they occur together. However, the characters m and o have a difference of 2 in their positions, which make them non-consecutive in nature. In this article, we are going to develop a code that takes as input a string, and displays true in case all the characters in a string are consecutive. Let us look at the following example ... Read More

Character whose frequency is equal to the sum of frequencies of other characters of the given string

Mallika Gupta
Updated on 31-Jul-2023 17:01:46

72 Views

Introduction A C++ string is a stream of alphanumeric characters. A string has the following properties − A string is composed of a fixed set of characters The strings positions start by default from the 0th index Frequency of any character is the number of times it occurs in the string. The frequency of any any character can range from 0 , if it doesn’t occur to the length of the string. In this article, we are going to develop a code that takes as input a string, and checks whether the frequency of any character is equivalent ... Read More

Count of pairs of strings which differ in exactly one position

Mallika Gupta
Updated on 31-Jul-2023 17:25:32

194 Views

Introduction A string is composed of alphanumeric characters, each of which is associated with a definite position. The positions of the characters range from 0 to the string length. The characters differing exactly in one position are said to be adjacent. In this article, we are going to develop a code that takes as input an array of strings which differ in exactly in one position. Let us look at the following example to understand the topic better − Sample Example Example 1 − str − {“abc”, “cba”, “dbc” , “acc”} Output − 2 For instance, in ... 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

Advertisements