Found 7346 Articles for C++

Make Given Binary Strings Equal by Replacing Two Consecutive 0s with Single1 Repeatedly

Mallika Gupta
Updated on 15-Mar-2023 11:12:06

216 Views

A binary string in any programming language is a collection of characters, 0 and 1. At every stage, the binary string follows the approach that the string can contain only these two characters. Consecutive characters in strings are the characters such that the difference in indices is 1. Let us consider two indices, i and j , they are said to be consecutive, if |j-i| = 1. Two strings in C++ are said to be equivalent if − The corresponding characters in both the strings are same. The length of the strings are equal as well as the characters ... Read More

Find distinct characters in distinct substrings of a string

Mallika Gupta
Updated on 15-Mar-2023 10:39:39

652 Views

A string is a sequence of characters, numbers and special characters. A string may contain multiple substrings. A substring of a given string is any sequence of characters taken in order. It must satisfy the following properties All the characters should be taken from the input string The indexes taken from the original string should be contiguous. The characters can’t be skipped from between. It may eliminate characters from the original string. All the characters taken from a particular string should be consecutive in nature. However, each substring may be composed of same or different characters. In this ... Read More

Count of non-overlapping sub-strings “101” and “010” in the given binary string

Mallika Gupta
Updated on 15-Mar-2023 10:33:58

565 Views

A binary string is a sequence of characters comprising of 0’s and 1’s only. A binary string can’t contain any other character. Some of the examples of binary strings are “0000”, ”01010” or “11111” A substring of a given string is a sequence of characters taken in order. A string may contain multiple substrings. Non-overlapping strings are the strings where the indices of any two found substrings should not collide with each other. This implies that for any two substrings substr1[a..b] and substr2[c..d], either of the following, bd should be true. The problem statement involves the computation of the ... Read More

Check if a given string can be formed by two other strings or their permutations

Mallika Gupta
Updated on 15-Mar-2023 10:27:21

364 Views

A string is a continuous stream of characters, numbers. It may even contain special characters. An string can be composed of multiple sub-strings, also referred by words. A permutation of a string is another string composed of the same set of characters, possibly arranged in a different order. It can basically be considered as a reordering of the string letters. For instance, abcd and badc are the permutations of the same string. Sample Examples Example 1 : str : “Permutation” arr : {“repuio”, ”mat”, “mtatn”, ”mutate”} Output :Yes The input string “Permutation” can be formed from the pair strings at ... Read More

Compute power of power k times % m

Simran Kumari
Updated on 23-Mar-2023 14:29:30

105 Views

Our objective to compute power of power k time % m, with the values of base, k and m provided as input − Look at the image above. Have you ever tried to compute such a problem? Let’s try it. Compute the power of power k times and then find modulo with m. Explanation In this question, x, k, and m are given. Compute ${x^{x{^x{^{^.{^{^.{^{^.}}}}}}}}}$ up to k times and then modulo with m. Let’s understand with an example. Given, x = 2, k = 4, and m = 6 So, Compute $2^{2^{2{^2}}}\:=\:4^{2{^2}}\:=\:16^2\:=\:256$ Then 256 % 6 ... Read More

Check whether an array can fit into another array by rearranging the elements in the array

Simran Kumari
Updated on 23-Mar-2023 14:27:13

241 Views

From the problem statement, we can understand that given two arrays, we have to check whether the first array can fit into the second array. In the real world, there are many instances where we need to check whether an array can fit into another array by rearranging the elements in the array. For a variety of reasons, programmers may need to reorder the items of an array to see if they can fit into another array. Memory management in computer programming is one such reason. When working with huge amounts of data, it is frequently more effective to use ... Read More

Run a Qt app in a different language

Satish Kumar
Updated on 14-Mar-2023 16:12:25

639 Views

Qt is a cross-platform application framework that is widely used for developing applications with graphical user interfaces. It is written in C++ and supports a range of programming languages, including Python, Ruby, and Java. One of most useful features of Qt is its support for internationalization, which allows developers to create applications that can be easily localized for different languages and cultures. In this article, we will discuss how to run a Qt app in a different language. Introduction to Internationalization Internationalization, also known as i18n, is process of designing and developing applications that can be easily localized for different ... Read More

Stormer Numbers

Rinish Patidar
Updated on 14-Mar-2023 15:07:04

204 Views

For N to be a stormer number, the highest prime factor of the expression N^2+1 must be greater than or equal to 2*N and it should be a positive integer. For example, 4 is a stormer number. Since 4*4+1=17 has the greatest prime factor 17 itself which is greater than 8 i.e. 2*4. But 3 is not a stormer number because 3*3+1=10. The greatest prime factor of 10 is 5 which is less than 6 i.e. 2*3. In this problem, we are given a positive integer N and our goal is to print the first N stormer. INPUT: 4 ... Read More

Print first n Fibonacci Numbers using Direct Formula

Rinish Patidar
Updated on 14-Mar-2023 15:05:24

710 Views

In this article, we are going to solve the problem of printing first n Fibonacci Numbers using a direct formula. In mathematics, the fibonacci numbers often denoted by Fn (which indicates nth fibonacci number), form a series in which each number is equal to the sum of the preceding two numbers. The nth fibonacci number can be indicates as below − $$\mathrm{Fn\:=\:F_{n-1}\:+\:F_{n-2}}$$ The series begins with 0 and 1. The first few values in the fibonacci sequence, starting with 0 and 1 are − 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144. ... Read More

Number of Ones in the Smallest repunit

Rinish Patidar
Updated on 14-Mar-2023 15:03:25

233 Views

In this problem, we simply need to print the number of ones in the smallest repunit. A repunit is a positive number like 11, 111, or 1111 in recreational mathematics that only has the digit 1. A repunit is of the form $\mathrm{(10*n-1)/9}$ Example $\mathrm{(10*10-1)/9}$ gives 11. $\mathrm{(10*100-1)/9}$ gives 111. $\mathrm{(10*1000-1)/9}$ gives 1111. The above problem states that we are given any positive integer N with its unit digit 3 and we need to determine the smallest repunit that is divisible by the given number N. For example, If we are given N=13. Output: 6 N i.e. 13 perfectly divides ... Read More

Advertisements