- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1862 Articles for Data Structure
150 Views
In this problem, we need to count the total number of substrings of string str containing exactly K distinct vowels. We can solve the problem in two different ways. The first approach is to traverse all substrings and count the number of vowels in each substring. We can also use the map data structure to optimize the code of the first approach. Problem statement – We have given string str of length N. The string contains uppercase and lowercase alphabetical characters. Also, we have given integer K. We need to find the total number of substrings of str containing exactly ... Read More
43 Views
In this problem, we need to find a total number of substrings of length K containing exactly K vowels. We will see two different approaches to solving the problem. We can use a naïve approach that checks the number of vowels in each substring of length K. Also, we can use the sliding window approach to solve the problem. Problem statement – We have given a string str of length N containing lowercase and uppercase alphabetical characters. We need to count the total number of substrings of length K which contains exactly X vowels. Sample examples Input– str = ... Read More
187 Views
In this problem, we need th check whether the substring S1 appears after any occurrence of the substring S2 in the given string S. We can compare the starting index of S1 and S2 in the string S to solve the problem. Problem statement – We have given three substrings named S, S1, and S2. The string S always contains S1 as a substring. We need to check whether the substring S1 appears after any occurrence of the substring S2 in the given string S. Sample examples Input – S = "abxtutorialspointwelcomepoint", S1 = "welcome", S2 = "point"; ... Read More
71 Views
We have given two strings and need to check whether the given string's permutations exist such that one permutation can have a larger character than another permutation at the ith index. We can solve the problem by sorting the string and comparing each character of the string one by one. Also, we can solve the problem using the frequency of characters of both strings. Problem statement – We have given a string str1 and str2 of length N. We need to check whether any permutations of both strings exist such that the permutation of one string is lexicographically larger than ... Read More
58 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
54 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
78 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
127 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
140 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
296 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