- 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 7347 Articles for C++
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
182 Views
Suppose we have a binary string s and an integer k. We have to check whether every binary code of length k is a substring of s. Otherwise, return False.So, if the input is like S = "00110110", k = 2, then the output will be true. The binary codes of length 2 are "00", "01", "10" and "11". These are present at indices 0, 1, 3, and 2 respectively.To solve this, we will follow these steps −Define one set vtemp := blank stringreq := 2^kfor initialize i := 0, when i < size of s, update (increase i by ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
241 Views
Suppose we have a binary tree where node values are digits from 1 to 9. One path in the binary tree is said to be pseudo-palindromic when at least one permutation of the node values in the path is a palindrome. We have to find the number of pseudo-palindromic paths going from the root node to leaf nodes.So, if the input is likethen the output will be 2, this is because there are three paths going from the root node to leaf nodes − red path follows [2, 3, 3], the green path follows [2, 1, 1], and the path ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
511 Views
Suppose we have a string s and an integer k. We have to find the maximum number of vowel letters in any substring of s with length k.So, if the input is like s = "abciiidef", k = 3, then the output will be 3To solve this, we will follow these steps −cnt := 0Define one set mfor each vowel v, doinsert v into mret := 0for initialize i := 0, when i < k, update (increase i by 1), do −cnt := cnt + (1 when s[i] is in m, otherwise 0)ret := maximum of ret and cntn := ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
91 Views
Suppose we have an array called favorite companies where favoriteCompanies[i] is the list of favorites companies of the ith person. We have to find the indices of people whose list of favorite companies is not a subset of any other list of favorites companies.So, if the input is like favoriteCompanies = [["TCS", "google", "facebook"], ["google", "microsoft"], ["google", "facebook"], ["google"], ["amazon"]], then the output will be [0, 1, 4], this is because person with index=2 has ["google", "facebook"] which is a subset of favoriteCompanies[0]= ["TCS", "google", "facebook"] corresponding to the person with index 0.Now person with index=3 has ["google"] which is ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
652 Views
Suppose we have a string with different words, that string is called sentence, and this is in the following format −First letter is in upper case.Each word in text are separated by a single space character.We have to rearrange the words in text such that all words are rearranged in increasing order of their lengths. If two words have the same length, arrange them in their original order.Then finally return the string by applying these rules.So, if the input is like "I love to code in cpp", then the output will be "I to in cpp love code"To solve this, ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
361 Views
Suppose we have a binary tree, a node X in the tree is named good when in the path from root to X there are no nodes whose value is greater than X. Here we have to find the number of good nodes in the binary tree.So, if the input is like, then the output will be 4, the colored nodes are good node.To solve this, we will follow these steps −Define a function dfs(), this will take node, val, if node is null, then −returnret := ret + (1 when val left){ if(val != NULL) ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
403 Views
Suppose we have an undirected tree consisting of n vertices and these are numbered from 0 to n-1, which has some apples in their vertices. We spend 1 second to walk over one edge of the tree. We have to find the minimum time in seconds we have to spend in order to collect all apples in the tree starting at vertex 0 and coming back to this vertex.Here the edges of the undirected tree are given in the array edges, where edges[i] = [from_i, to_i] this means that exists an edge connecting the vertices from_i and to_i. Additionally, there ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
195 Views
Suppose we have an array of integers arr. We want to select three indices like i, j and k where (0 = 0; j--) { x1 = x1 ^ arr[j]; m[x1]++; } for (int j = i; j < n; j++) { x2 = x2 ^ arr[j]; ret += m[x2]; } } return ret; } }; main(){ Solution ob; vector v = {2,3,1,6,7}; cout
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
427 Views
Suppose we have an array of integers called nums and an integer limit, we have to find the size of the longest non-empty subarray such that the absolute difference between any two items of this subarray is less than or equal to the given limit.So, if the input is like nums = [8, 2, 4, 7], limit = 4, then the output will be 2, this is because −[8] so |8-8| = 0 4.[8, 2, 4] so |8-2| = 6 > 4.[8, 2, 4, 7] so |8-2| = 6 > 4.[2] so |2-2| = 0 k) { ... Read More