Found 34494 Articles for Programming

Number of Times the given String Occurs in the Array in the Range [l, r]

Sonal Meenu Singh
Updated on 18-Aug-2023 16:19:30

61 Views

Introduction In this tutorial, we implement examples using C++ to find the number of times an input string occurs in an array of the range [l, r]. Only lowercase alphabets are used in the string array to resolve this task. Different strings are stored in the string array and traversed to check if a particular string exists. This is for a given range of L and R. L and R are the starting and ending index values of an array to search a string for that range in the input string array. Find string lying between L and R of ... Read More

Minimum Number of Substrings of a String such that all are Power of 5

Sonal Meenu Singh
Updated on 18-Aug-2023 16:09:12

104 Views

Introduction In this tutorial, we implement 2 examples using C++ to find the minimum number of substrings in a given string. Those substrings are all powers of 5 that means, the substrings are the factors of the number 5. To implement the example, take an input binary string and generate the minimum possible substrings that are factors of 5. If you want to know whether a substring is a power of 5 or not, check its decimal values. The binary string is a combination of 1 and 0 and we cannot find a particular binary string that is ... Read More

Minimum Cost to Modify a String

Sonal Meenu Singh
Updated on 18-Aug-2023 13:55:29

211 Views

Introduction In this tutorial, we use C++ programming concepts to implement examples to find the minimum cost to modify a string. String modification includes operations to change one string into another string. String operations include insertion, deletion, and substitution. We predefined the cost of each operation. You can choose the cost values of your choice. Generate output by calculating the total operation cost for string modification. The insertion function is used to insert missing characters, deletion is used to remove unwanted characters, and the substitution operation is used to replace a character with another character. For implementing the above ... Read More

Maximum Length Palindrome of a String that can be Created with Characters in Range L and R

Sonal Meenu Singh
Updated on 18-Aug-2023 13:54:04

91 Views

Introduction A palindrome is one that reads the same forward and backward. An example of a palindrome string is Mam. In this tutorial, we use C++ programming to find the maximum length palindrome of a string by predefining the range of characters. Our task is to find the largest length of a palindrome string using the input string. We define the range of characters to generate that string. Depending on the situation, L and R can hold any value. Demonstration 1 String = “amem” Range = {1, 4} Output 3 In the above demonstration, the ... Read More

Longest substring of only 4’s from the first N Characters of the Infinite String

Sonal Meenu Singh
Updated on 18-Aug-2023 12:54:01

68 Views

Introduction In this tutorial, we implement an approach to find the longest substring of only 4 using the first N characters of the infinite string. Infinite string using 4 looks like this: “44444444……” and for this string we define the length of characters to consider for solving the task. To solve the problem of this tutorial, consider an input numerical string, We solve this problem using two conditions and those conditions are as follows: Consider an input string with random digits and generate the longest substring of 4’s from the string. We consider an infinite string of combinations of ... Read More

Largest Component Size in a Graph Formed by Connecting Non-Co-Prime Nodes

Sonal Meenu Singh
Updated on 22-Aug-2023 17:12:55

72 Views

Introduction In this tutorial, we discuss the problem of finding the largest component size in a graph generated by connecting non-co-prime nodes through C++. Graphs are formed by nodes connected by edges. The components of the graph are a subset of values that form nodes. There is an array a[] which forms graph G. The components of the graph are a subset of values that form nodes. The non-coprime numbers are the numbers that have a HCF (Highest Common Factor) other than 1, that means they have some other common factors. We solve the problem statement in this tutorial using ... Read More

Introduction to the Probabilistic Data Structures

Sonal Meenu Singh
Updated on 18-Aug-2023 12:25:38

538 Views

Introduction In this tutorial, we will discuss probabilistic data structures in detail. This tutorial will cover the meaning of a Probabilistic Data Structure, its types, and its benefits. When dealing with large data sets or Big Data, basic data structures that use hashtables or HashSets would not be effective enough. As the data size increases, memory requirements increase with limited time for solving a query which restricts the functionality of deterministic basic data structures. Probabilistic data structures are approximate data structures that are collections of data structures. They are called so because they do not provide exact values. They ... Read More

Given a String and an Integer k, find the kth Substring when all the Substrings are Sorted According to the given Condition

Sonal Meenu Singh
Updated on 18-Aug-2023 12:23:25

84 Views

Introduction In this tutorial, we implement an approach to find the kth substring after sorting all the substrings according to some conditions for a given string and the value of k. The condition to sort the substring is that the substrings are alphabetical while producing the substring in the order of their occurrence of each character in the alphabet. The first alphabet generates all its substrings, then the second alphabet produces all its substrings, and so on. Consider an example: the input string is “abc”, the alphabetically sorted substrings are “a”, “ab”, “abc”, “b”, “bc”, “c”. Predefined the value of ... Read More

Generate all Permutations of a String that follow given Constraints

Sonal Meenu Singh
Updated on 18-Aug-2023 11:31:47

265 Views

Introduction In this tutorial, we implement two examples using C++ programming concepts to generate all permutations of an input string. Permutation of a string is the number of ways a string can be arranged by interchanging the position of characters. We also include some constraints or limitations. All permutations or arrangements of the input string ensure character B does not follow character A anywhere, meaning there is no AB combination in the string. To implement this task we use two approaches: Directly generate all combinations of the string while restricting AB. Using backtracking. Demonstration 1 String = ... Read More

Capitalize the First and Last Character of Each Word in a String

Sonal Meenu Singh
Updated on 18-Aug-2023 11:28:04

338 Views

Introduction In this tutorial, we implement an approach to capitalizing the first and last characters of each word in the input string. By iterating over the input string str, each word's starting and ending letters are capitalized. We implement this problem using C++ programming in two ways. Let's start this tutorial with some demonstrations. Demonstration 1 String = “coding world” Output CodinG WorlD In the above demonstration, consider the input string and the result after capitalizing the starting and ending character of each word of the string is CodinG WorlD. Demonstration 2 String = “`hello all” ... Read More

Advertisements