Found 7197 Articles for C++

C++ Program for Longest subsequence of a number having same left and right rotation

Shubham Vora
Updated on 17-Aug-2023 17:37:18

135 Views

In this problem, we need to find the maximum length of the sub sequence with the same left and right rotations. The left rotation means moving all characters of the string in the left direction and the first character at the end. The right rotation means moving all string characters in the right direction and the last character at the start. Problem statement – We have given string str containing numeric digits and need to find the sub sequence of maximum length with the same left and right rotations. Sample examples Input – str = "323232", Output – 6 Explanation– ... Read More

Average value of set bit count in given Binary string after performing all possible choices of K operations

Shubham Vora
Updated on 17-Aug-2023 17:34:43

125 Views

In this problem, we need to find the average value of the count of set bits after performing K operations of all choices on the given string. There can be a brute force approach to solve the problem, but we will use the probability principles to overcome the time complexity of the brute force approach. Problem statement – We have given an integer N, array arr[] containing K positive integers, and a binary string of length N containing only set bits. We need to find the average value of the count of set bits after performing all possible choices ... Read More

Count of K length substring containing at most X distinct vowels

Shubham Vora
Updated on 17-Aug-2023 17:31:46

230 Views

In this problem, we need to find the total number of sub strings of length K containing at most X distinct vowels. We can solve the problem in two different ways. The first way is to get all sub strings and count distinct vowels in each sub string of length K. The second way is to use a map data structure and track the number of distinct vowels in the particular sub string. Problem statement– We have given string str of length N. The string contains only alphabetical characters. Also, we have given K and X positive integers. We need ... Read More

Check if the Sum of Digits of a Number N Divides It

Tapas Kumar Ghosh
Updated on 17-Aug-2023 18:19:17

307 Views

The N number is the special number of integer type that calculates the individual digit of sum. So, this sum will be divisible by its own number. Let’s take an example of this. The given integer number, N = 36 The sum of each digit, 3 + 6 = 9 Therefore, 36 is successfully divisible by 9 and it verifies for N divides it. Algorithm The following steps are- Step 1: We will start the program by mentioning the header file iostream. Step 2: Common Matches:- Then used the function definition digit_sum() that accepts the parameter a variable n ... Read More

How do I link a C++ program with an HTML page?

Ayush Singh
Updated on 17-Aug-2023 11:03:14

10K+ Views

WebAssembly (Wasm), a parallel guidance design that empowers superior execution dialects like C++ to execute in internet browsers, is utilized to connect a C++ application with a HTML page. Engineers can make online applications with C++ usefulness because of WebAssembly, which empowers consistent coordination of C++ code with HTML and JavaScript. Here is a bit by bit instructional exercise for using WebAssembly to interface a C++ program with a HTML page. Install the Required Tools Before you begin, you should set up the accompanying equipment − If you don't already have a C++ compiler, consider installing GCC (GNU Compiler ... Read More

Is there any equivalent to typedef of C/C++ in Java?

Shriansh Kumar
Updated on 17-Aug-2023 09:57:11

842 Views

We can find many similarities between Java and C/C++ programming languages in terms of syntaxes and features. But, there are several functionalities that have been omitted from Java like 'typedef'. If someone coming from a C/C++ background, must have heard the 'typedef' keyword, and often wonders, is there any equivalent to typedef in Java? In simple words, Java does not provide a direct equivalent to typedef. The creators of Java replaced this feature with classes. In fact, a class can do even more than a typedef can do. Replacement to typedef of C/C++ in Java? Before exploring the ... Read More

Check Duplicate in a Stream of Strings

Tapas Kumar Ghosh
Updated on 16-Aug-2023 15:53:12

459 Views

The stream of strings is a sequential flow of given data where an individual element of the stream represents a string. The stream allows a large process of string data In C++, we have some STL(Standard template library) based functions such as count() and insert() to Check duplicate in a stream of strings. Using Standard Template Library The program uses C++ STL to set the header file unordered representing the unique key element and helps to solve the duplicates in a stream of strings. Syntax The following syntax is used in the examples- static unordered_set unq_string; The ... Read More

Check whether all the substrings have number of vowels atleast as that of consonants

Tapas Kumar Ghosh
Updated on 16-Aug-2023 15:35:35

250 Views

In Alphabetical series there are consists of 26 characters of which 5 characters are vowels such as a, e, i, o, u and the rest are called as consonants. In C++, we have predefined functions such as tolower() and length() that will help to Check whether all the substrings have number of vowels atleast as that of consonants. Let’s take an example of this. The string has only one consonant with the rest vowel “aiteau”. Hence, it is accepted as the final result. The string has more than one consonant with the rest vowel “appioa”. Hence, it is not ... Read More

XOR of two numbers after making the length of their binary representations equal

Eva Sharma
Updated on 16-Aug-2023 11:00:13

274 Views

XOR, or exclusive OR, is a boolean logic operation which is used in generating parity bits for error checking, fault tolerance, etc. Various symbols are used to represent this operation: ^, ⊕, ⊻, etc. XOR Logic The XOR operation is only true if the two arguments are different. This means that the XOR of the same bits is 0, and that of different bits is 1. Same bits − 0 ^ 0 = 0 1 ^ 1 = 0 Different bits − 0 ^ 1 = 1 1 ^ 0 = 1 Problem Statement Given two numbers, a and b, ... Read More

The time when the minute hand and the hour hand coincide after a given hour

Eva Sharma
Updated on 16-Aug-2023 10:57:39

799 Views

When the minute hand moves from 12 to 12 in one hour, the hour hand also moves from the previous hour to the next. Hence, every hour, the minute hand and the hour hand coincide once. Problem Statement Given an input hour, find the time in minutes when the hour hand and the minute hand coincide within the next hour. Examples Input − Hour = 4 Output − Coinciding time: 240/11 minutes. We will discuss the explanation further with the approach. Input − Hour = 5 Output − Coinciding time: 300/11 minutes. Explanation and the Approach ... Read More

Advertisements