
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++

469 Views
The 132 pattern indicates that, as the digits in "132" in any given value, the middle element should be greater than the last and first elements. Similarly, the last element must be greater than the first element. To check 132 patterns in C++, we will use the Array data structure. We have given an array nums[] of size S. Our task is to check whether the array elements at indices i, j, and k are such that i < j < k and nums[j] < nums[k] and nums[i] < nums[k]. If any three elements at positions i < j < k ... Read More

603 Views
Suppose we have a string representing arbitrarily nested ternary expressions, we have to calculate the result of the expression. we can always assume that the given expression is valid and only consists of digits 0-9, ?, :, T and F these few characters. (Here T and F represent True and False respectively). There are some properties −The length of the given string must be less than or equal to 10000.Each number will contain only one digit.The conditional expressions group right-to-left.The condition will always be either T or F. So the condition will never be a digit.The result of the expression ... Read More

416 Views
Suppose we have a of intervals, for each of the interval i, check whether there exists an interval j whose start point is bigger than or equal to the endpoint of the interval i, which can be called that j is on the "right" of i. For any interval i, we have to store the minimum interval j's index, which indicates that the interval j has the minimum start point to build the "right" relationship for interval i. When the interval j doesn't exist, then store -1 for the interval i. And finally, we need output the stored value of ... Read More

207 Views
Suppose we have a rows x cols screen and a sentence represented by a list of non-empty words, so we have to find how many times the given sentence can be fitted on the screen. There are certain properties −A word will not be split into two lines.The order of words in the sentence must not be changed.There will be only one space between two words.The total number of words in the sentence won't exceed 100.The length of each word is greater than 0 but less than 10.1 ≤ rows, cols ≤ 20, 000.So if the input is like rows ... Read More

309 Views
Suppose we have a sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. So for example, these are arithmetic sequence: [1, 3, 5, 7, 9], [7, 7, 7, 7], [3, -1, -5, -9], But the following sequence is not arithmetic. [1, 1, 2, 5, 7]Now a zero-indexed array A consisting of N numbers is given. A slice of that given array is any pair of integers (P, Q) such that 0

737 Views
Suppose we have a non-negative integer num that is represented as a string, we have to remove k digits from the number so that the new number is the smallest possible. So if the input is like “1432219” and k = 3, then the result will be “1219”.To solve this, we will follow these steps −Define a stack st, create an empty string retn := size of numfor i in range 0 to n – 1while k is non zero and stack is not empty and top of stack > num[i]delete from the stack and decrease k by 1insert num[i] ... Read More

1K+ Views
Suppose we have one infinite integer sequence, we have to find the nth digit of this sequence. So if the input is 11, then the output will be 0 as if we place the numbers like 123456789101112, so the 11th digit is 0.To solve this, we will follow these steps −len := 0 and cnt := 9 and start := 1while n > len * cntn := n – (len * cnt)cnt := cnt * 10, start := start * 10increase len by 1start := start +(n - 1) / lens := start as stringreturn s[(n – 1) mod len]Example ... Read More

6K+ Views
In this article, we have a string. Our task is to reverse the words in the given string. Here is an example of reversing the words of a string: Example The example below reverses the words of the given string: Input: "I am Viper" Output: Viper am I Here are the approaches to reverse the words of a string: Using Two Pointer Approach Using STL reverse() Function Using stringstream with Vector Using Recursive Approach ... Read More

192 Views
Suppose we have a singly linked list where elements are sorted in ascending order, we have to convert it to a height balanced BST. So if the list is like [-10, -3, 0, 5, 9], The possible tree will be like −To solve this, we will follow these steps −If the list is empty, then return nullDefine a recursive method called sortedListToBST() this will take list start nodex := address of the previous node of mid node from list amid := exact mid nodecreate a new node with value by taking from the value of midnextStart := next of mid ... Read More

616 Views
In this article, we will understand the four divisors problem. We have an array of integers, and our task is to find the sum of divisors of the array elements that have exactly four divisors. If there is no such integer in the array, then return 0. Here is a detailed example given below: Example The following example implements four divisors sum problem: Input: arr = [5, 10, 15, 8] Output: 57 The explanation of the above example is as follows: Divisors of 5 = (1, 5) => count != ... Read More