Data Structure Articles

Page 59 of 164

Count of buttons pressed in a keypad mobile

Mallika Gupta
Mallika Gupta
Updated on 31-Jul-2023 373 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
Mallika Gupta
Updated on 31-Jul-2023 2K+ 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
Mallika Gupta
Updated on 31-Jul-2023 227 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

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

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 28-Jul-2023 369 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

The camel case character present in a given string

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 28-Jul-2023 994 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
Thanweera Nourin A V
Updated on 28-Jul-2023 2K+ 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

Maximum possible balanced binary substring splits with at most cost k

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 28-Jul-2023 223 Views

The array in the C programming language has a fixed size, which means that once the size is specified, it cannot be changed; you can neither shrink it or extend it. As we know, an array is a group of identically data-typed elements kept in consecutive memory regions. Given an array of values v[] and a binary array a[]. The objective is to use as many k coins to divide the binary array as much as is possible while ensuring that each segment has an equal amount of 0s and 1s. i and j are the neighboring indices of the ...

Read More

Decode a given string by removing duplicate occurrences

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 28-Jul-2023 275 Views

The aim of this article is to implement a program to decode a given string by removing duplicate occurrences. As you are aware of what a string is, a string is nothing but a collection of characters. Also there is no restriction in the repetitions of characters in a string. A string can have the same character occurring multiple times. In this we will figure out a way to decode a given encoded string str by removing duplicate occurrences. The objective would be to decode the provided string str, which has been encoded with 'a' appearing just once, 'b' twice, ...

Read More

Count of N-length binary strings that are repeated concatenation of a substring

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 28-Jul-2023 240 Views

The aim of this article is to implement a program to count of N-length binary strings that are repeated concatenation of a substring. The goal is to determine how many binary strings of the length N can be created by repeatedly concatenating a single substring of a given text, provided a positive integer called N. Problem Statement Implement a program to count of N-length binary strings that are repeated concatenation of a substring. Sample Example 1 Let us take the Input, N = 3 Output: 2 Explanation Listed below are the feasible binary string of length N=3 with ...

Read More

Count of N digit numbers not having given prefixes

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 28-Jul-2023 213 Views

Here the problem is to determine the total number of strings of the length N containing characters '0' through '9' provided an integer N with an array of string prefixes pre[]. such that none of the strings can contain the provided prefixes. The aim of this article is to implement a program to find the count of N digit numbers not having given prefixes. A collection of various strings is referred to as an array in the C programming language because an array is a linear grouping of data pieces of a similar type. As we already know, the string ...

Read More
Showing 581–590 of 1,635 articles
« Prev 1 57 58 59 60 61 164 Next »
Advertisements