
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 1860 Articles for Data Structure

182 Views
In this problem, we need to maximize the ‘10’ subsequences in the given binary string by replacing the 0 or 1 ‘0’ character with ‘1’. We can replace each ‘0’ with ‘1’ one after another and find a maximum number of ‘10’ subsequences in the updated string. Problem statement − We have given a binary string named str1 containing only 0 and 1 characters. We can replace at most one ‘0’ with ‘1’ and need to find the maximum number of ‘10’ subsequences in the given string. Sample Examples Input str1 = "10110" Output 4 Explanation The ‘10110’ ... Read More

243 Views
In this problem, we will find the longest substring of A to convert it to a substring of B starting from the same index in less than T cost. We will use the binary search algorithm to find the maximum length of the substring which follows the given condition. However, the naïve approach to solving the problem is to find all substrings following the conditions in the problem statement and take the substring with maximum length. Problem statement − We have given a string A and B of length N. Also, we have given a total cost, ‘T’. The ... Read More

1K+ Views
In this problem, we will use the regular expression to validate the ISIN number in C++. The ISIN stands for the International Securities Identification Number. It is a unique code to identify stocks, financial bonds, etc. The length of the ISIN number can be 12 or 14, which provides international recognization of the particular stuff. Let’s understand the format of the ISIN number. Country code − It starts with two characters of the country code. Identifier − It contains 9 alphanumeric characters after the country code. Checksum − It contains the single digit which is used to detect errors ... Read More

164 Views
In this problem, we will construct two palindromic strings using the given string’s characters. We can use the character’s frequency to solve the problem. We can construct two new palindromic strings only if both characters’ frequencies are even or if any characters have an even frequency and others have an odd frequency. Problem statement − We have given a string alpha containing two different characters and a size equal to N. We need to construct two palindromic strings using the characters of the alpha, which are not the same as the given string alpha. Sample Examples After incrementing each character ... Read More

157 Views
In this problem, we need to increase each character of multiple prefixes of size given in the array. The naïve approach to solving the problem is to take each prefix of the size given in the array and increment each character of the prefix by 1. The best approach is to create the prefix array using the given array and update each string character in the single iteration. Problem statement − We have given a string alpha of length N. Also, we have given a prefixes array containing the positive integer. The prefixes[i] represent that take prefix of length prefixes[i] ... Read More

240 Views
In this problem, we will find the number of pairs of 3 indices so that any adjacent indices don’t have the same value in the pair. We can get the output by checking each pair of 3 indexes, but it can be more time-consuming. Another approach to solving the problem is to take the current index and also take the index from left and right, which doesn’t contain a similar value to the current index's value. This way, we can count the total number of pairs each index can form and sum them to get the output. Problem statement − ... Read More

167 Views
In this problem, we will find total invalid characters in the given string. If total distinct characters till the particular even index is prime, we can say the character is invalid. We can use the map data structure to count the total number of distinct characters while traversing the string. Also, we can use the string of characters to keep track of the distinct digits. Also, for every character, we can check whether its index is even and whether distinct characters are prime. Problem statement – We have given a string alpha containing the N characters. We need to find ... Read More

155 Views
In this problem, we will check if it is possible to divide the given numeric string into two disjoint subsequences such that sum(sub1) * sum(sub2) becomes odd. We need to divide the string into two subsequences such that the sum of the digits of both becomes odd to get the odd multiplication result. Problem statement − We have given a string num_string containing the numeric characters. We need to check whether we can divide the string into two subsequences such that the multiplication of the sum of both subsequences becomes odd. Also, it is given that every character of the ... Read More

354 Views
The problem statement includes counting the odd numbers in N−th row of Pascal’s triangle. A pascal’s triangle is a triangular array where each row represents the binomial coefficients in the expansion of binomial expression. The Pascal’s triangle is demonstrated as below: 1 1 ... Read More

286 Views
The problem statement includes printing the first N terms of the Moser−de Bruijn Sequence where N will be given in the user input. The Moser−de Bruijn sequence is a sequence consisting of integers which are nothing but the sum of the different powers of 4 i.e. 1, 4, 16, 64 and so on. The first few numbers of the sequence include 0, 1, 4, 5, 16, 17, 20, 21, 64....... The sequence always starts with zero followed by the sum of different powers of 4 such as $\mathrm{4^{0}}$ i.e $\mathrm{4^{1}\:i.e\:4, }$ then sum of $\mathrm{4^{0}\:and\:4^{1}\:i.e\:5}$ and so on. In this ... Read More