
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 7197 Articles for C++

122 Views
In the English language while writing a sentence we need to start with the capital character and for any name of the city/person, etc we begin with the capital letter. Here in this problem, we are given a string and a number and we have to update the first character of all the words of the given string if their size is not less than k. Also, if the size of the words is more than k and their first character is already capitalized then we will leave it as it is. Sample Examples Input string str ... Read More

229 Views
Splitting the array means we have to divide the array and make subsets. Here in this problem, we have given an array of integers with size n and integer k and our goal is to calculate the lowest cost by splitting the whole given array into the subsets of size k and adding the highest k/2 element of each subset into the cost. NOTE: here we consider a ceiling of k/2. Let’s see examples with explanations below to understand the problem in a better way. Sample Example Input n: 4 array: [ 3, 4, 2, 1 ... Read More

167 Views
In this problem, we will find the substring of the given string whose character's ASCII value's sum is maximum when we redefine the ASCII values. The naïve approach to solve the problem is to find the sum of all substring's character's ASCII value and get the substring having maximum sum. Another approach to solving the problem is using Kadane's algorithm to find the maximum sub-array sum. Problem statement - We have given a string alpha of size N containing the alphabetical characters. We have also given the chars[], and ASCII[] array of size M, where chars[] contains ... Read More

174 Views
In this problem, we need to split the parenthesis string into valid groups. When all opening brackets have related closing brackets, we can say that the group of parenthesis is valid. Problem Statement We have given a string containing open and closed parentheses. We need to split the string to get the maximum valid parenthesis string. Sample Examples Input: par = "(())()(()())" Output: (()), (), (()()), Explanation Each substring contains the valid parentheses sequence. Input: par = "()()" Output: (), () Explanation We have splited the string into two groups. Input: ... Read More

184 Views
In this problem, we will count the number of minimum operations required to convert string non-decreasing order by flipping the characters of the binary string. We can flip all characters of the substring starting from the \mathrm{p^{th}} index if the character at the pth index is 0 and not matching with character at the previous index, and we can count the minimum flips. Problem statement - We have given a binary string alpha. We need to count the minimum flips required to convert the binary string in increasing order. In one flip, we can select any index p ... Read More

156 Views
In this problem, we will find the maximum points while converting the string S to T according to the conditions in the problem statement. We can traverse the string S and make each character of the string S same as string T's character at the same index by maximum swaps to get maximum points. In the other approach, we will prepare a mathematical formula based on the string's observation to get the answer. Problem statement - We have given a string S and T containing the alphabetical and numeric characters. We need to count the maximum ... Read More

178 Views
In this problem, we need to find the maximum OR value of any two substrings of the given strings. The first approach is to find all substrings of the given binary string, take OR value of each string, and print the maximum OR value. The other approach is to take the original string as one substring and take another substring starting from left most zero to maximize the OR value. Problem statement - We have given a binary string alpha. We need to find the maximum OR value of any two substrings of the given binary ... Read More

225 Views
In this problem, we will count the number of binary strings of size N, containing at most 2 adjacent distinct pair of characters. It means the string should contain, at most, 2 '01' 0r '10' pairs. The first approach is that generate all binary strings, and if any binary string contains less than or equal to 2 distinct pairs of characters, include its count in the result. For the optimal solution, we can count a number of binary strings containing 0, 1, and 2 adjacent different pairs and sum them. Problem statement - We have given a positive ... Read More

143 Views
In this problem, we need to count substrings containing a minimum 1 occurrence of all K characters. Here, we will use two different approaches to solve the problem. The first approach takes all substrings of the given string, checks whether the substring contains all K characters, and counts such substrings containing all K characters. The second approach uses the sliding window technique to solve the problem. Problem statement - We have given a string alpha containing N characters. Also, we have given K, representing the string containing multiple occurrences of only the first K alphabetical characters. We ... Read More

297 Views
In this problem, we will count the number of strings containing query string as a prefix for each query string. We can traverse the list of query strings, and for each query, we can find a number of strings containing it as a prefix. Also, we can use the trie data structure to solve the problem. Problem statement – We have given an strs[] and queStr[] string array containing N and Q strings, respectively. We need to count the number of strings from the Strs[] array containing the queStr[i] string as a prefix for each string of ... Read More