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

311 Views
Suppose we have a rectangle of size n x m. We have to find the minimum number of integers sided square objects that can tile the rectangles.So, if the input is like n = 2 and m = 3,then the output will be 3, as we need three blocks.To solve this, we will follow these steps −Define one map mres := infDefine a function dfs(), this will take n, m, an array h, cnt,if cnt >= res, then −returnisFull := truepos := -1, minH := inffor initialize i := 1, when i

1K+ Views
Suppose we have n different tasks, where every task is scheduled to be done from startTime[i] to endTime[i], for that task we algo get profit of profit[i]. We know the startTime , endTime and profit lists, we have to find the maximum profit we can take such that there are no 2 tasks in the subset with overlapping time range. If we choose a task that ends at time X we will be able to start another task that starts at time X.So, if the input is like startTime = [1, 2, 3, 3], endTime = [3, 4, 5, 6] ... Read More

270 Views
Suppose we have an array nums of positive integers, we have to return the longest possible length of an array prefix of given array nums, such that it is possible to delete exactly one element from this prefix so that every number that has appeared in it will have the same frequency. After removing one element if there are no remaining elements, it's still considered that every appeared number has the same frequency (0).So, if the input is like [3, 3, 2, 2, 6, 4, 4, 6], then the output will be 7, So if we remove element 6 from ... Read More

285 Views
Suppose we have one number n, we have to count how many strings of length n can be formed using these rules − Each character is a lower case vowel Each vowel 'a' may only be followed by an 'e'. Each vowel 'e' may only be followed by an 'a' or 'i'. Each vowel 'i' may not be followed by another 'i'. Each vowel 'o' may only be followed by an 'i' or 'u'. Each vowel 'u' may only be followed by an 'a'. The answer may be too large, so we will find the answer modulo 10^9 + 7.So, ... Read More

496 Views
Suppose there are n servers. And these are numbered from 0 to n-1 connected by an undirected server-to-server connections forming a network where connections[i] = [a, b] represents a connection between servers a and b. All servers are connected directly or through some other servers. Now, a critical connection is a connection that, if that is removed, it will make some server unable to reach some other server. We have to find all critical connections.So, if the input is like n = 4 and connection = [[0, 1], [1, 2], [2, 0], [1, 3]], then the output will be [[1, ... Read More

403 Views
Suppose we have two arrays arr1 and arr2, these can store integer numbers. We have to find the minimum number of operations needed to make arr1 strictly increasing. Here, we can choose two indices 0 size of arr2, then -1, otherwise ret - 1)Let us see the following implementation to get better understanding −Example Live Demo#include using namespace std; class Solution { public: int solve(vector& arr1, vector& arr2, int i, int j, int prev, vector& dp){ if (i >= arr1.size()) return 1; j = upper_bound(arr2.begin() + j, ... Read More

301 Views
Suppose we have s as string, we have to find the last substring of s in lexicographic order.So, if the input is like "abbbcabbc", then the output will be "cabbc"To solve this, we will follow these steps −i := 0, j := 1, k := 0while j + k < size of s, do &minsu;if s[i + k] is same as s[j + k], then −(increase k by 1)Ignore following part, skip to the next iterationif s[i + k] < s[j + k], then −i := j(increase j by 1)Otherwisej := j + k + 1k := 0return substring of ... Read More

206 Views
Suppose we have two strings str1 and str2, we have to find the shortest string that has both str1 and str2 as subsequences. There may be more than one results, so we will return only one of them.As you know a string S is called a subsequence of string T if deleting some number of characters from T (possibly 0, and the characters are chosen anywhere from T) results in the string S.So, if the input is like "acab", "bac", then the output will be "bacab", this is because two given strings are subsequence of this.To solve this, we will ... Read More

229 Views
Suppose we have a matrix, and a target value, we have to find the number of non-empty submatrices that sum is same as target. Here a submatrix [(x1, y1), (x2, y2)] is the set of all cells matrix[x][y] with x in range x1 and x2 and y in range y1 and y2. Two submatrices [(x1, y1), (x2, y2)] and [(x1', y1'), (x2', y2')] are different if they have some coordinate that is different: like, if x1 is not same as x1'.So, if the input is like010111010and target = 0, then the output will be 4, this is because four 1x1 ... Read More

658 Views
Suppose we have a string S, consider all duplicated contiguous substrings that occur 2 or more times. (The occurrences may overlap.), We have to find the duplicated substring that has the longest possible length. If there is no such substrings, then return a blank string. As the answer may very large, so return in mod 10^9 + 7.So, if the input is like "ababbaba", then the output will be "bab"To solve this, we will follow these steps −m := 1e9 + 7Define a function add(), this will take a, b, return ((a mod m) + (b mod m)) mod mDefine ... Read More