Found 34489 Articles for Programming

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

134 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

915 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

73 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

195 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

Java Program to Find the Largest Independent Set in a Graph by Complements

Ayush Singh
Updated on 31-Jul-2023 16:33:50

63 Views

Here's a Java programme executed in C to discover the biggest autonomous set in a chart utilising the complement chart approach. The programme, to begin with, builds the complement chart of the given input chart. At that point, it emphasises each vertex within the complement chart and recursively finds the greatest free set (MIS) by counting or barring the current vertex. The programme keeps track of the estimate of the most extreme free set found so far and returns it as the ultimate result. By utilising the complement chart, we are ready to change the issue of finding the biggest ... Read More

Java Program to Find a Good Feedback Vertex Set in a Graph

Ayush Singh
Updated on 31-Jul-2023 16:33:07

80 Views

The Java programme points to a great Input Vertex Set in a chart. An Input Vertex Set may be a set of vertices in a chart such that expelling those vertices and their occurrence edges comes about in a non-cyclic chart. The programme utilises an algorithmic approach to recognise a small Input Vertex Set that maintains the graph's basic properties. By iteratively selecting vertices with high degrees and evacuating them at their occurrence edges, the programme finds an assumed arrangement. This permits proficient distinguishing proof of critical vertices that contribute to cycles within the chart. The coming Criticism Vertex Set ... Read More

Check if left and right shift of any string results into given string

Sakshi Koshta
Updated on 31-Jul-2023 16:12:50

268 Views

A collection of characters is represented by a string data type. It is arranged logically using letters, numbers, symbols, and empty spaces. The majority of computer languages enclose strings in single or double quotation marks to distinguish them from other data types. Programmers frequently employ strings to carry out some input and output operations, the storing, and the manipulation of textual data, and more. Concatenation (combining two or more strings), substring extraction (obtaining a segment of a string) and searching for certain characters or patterns inside a string are some frequent operations that can be carried out on strings. Methods ... Read More

Length of the smallest substring which contains all vowels

Sakshi Koshta
Updated on 31-Jul-2023 16:11:01

143 Views

One common issue encountered during string manipulation assignments involves identifying the shortest substring containing every vowel atleast once. This task finds its application amongst varied domains such as data analytics, bioinformatics and natural language processing among others.The goal here is finding out which minimum contiguous section within an existing string has each of these five letters (a, e, i, o, u) atleast once.The selection process for resolving this challenge encompasses multitude techniques like implementing sliding window algorithms or incorporating hashing procedures or utilizing regular expressions etcetera.Finding a robust resolution for this problem typically becomes crucial since numerous real-world scenarios demand ... Read More

How to validate MasterCard number using Regular Expression?

Sakshi Koshta
Updated on 31-Jul-2023 16:03:46

309 Views

Mastercard is a multinational financial services company that has provided payment processing services to clients globally since its establishment in 1966. Its headquarters remain based in New York, USA. It marked as one of the biggest payment systems in the world, with rivals Visa and American Express. They stand out and are well fitted for both of the consumer and business need due to the large range of goods they provide, which may involve credit cards, debit cards, and prepaid cards. Among them are prepaid cards, debit cards, and credit cards. To distribute these card options globally, it works ... Read More

Advertisements