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

143 Views
Suppose we have a matrix M with dimensions w x h, such that every cell has value 0 or 1, and any square sub-matrix of M of size l x l has at most maxOnes number of ones. We have to find the maximum possible number of ones that the matrix M can have.So, if the input is like w = 3, h = 3, l = 2, maxOnes = 1, then the output will be 4 as in a 3*3 matrix, no 2*2 sub-matrix can have more than 1 one. The best solution that has 4 ones is −101000101To ... Read More

877 Views
Suppose we have a digit, now if we rotate that digit by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, they become 0, 1, 9, 8, 6 respectively. But when 2, 3, 4, 5 and 7 are rotated 180 degrees, they become invalid.A confusing number is a number that when rotated 180 degrees becomes a new number. So, if we have a positive integer N, we have to find the number of confusing numbers between 1 and N inclusive.So, if the input is like 20, then the output will be 6To solve ... Read More

1K+ Views
Suppose we have an integer d between 0 and 9, we also have two positive integers low and high as lower and upper bounds, respectively. We have to find the number of times that d occurs as a digit in all integers between low and high, including the bounds low and high.So, if the input is like d = 1, low = 1, high = 13, then the output will be 6, as digit d=1 occurs 6 times like 1, 10, 11, 12, 13.To solve this, we will follow these steps −Define a function zero(), this will take n, ret ... Read More

464 Views
Suppose we have an array A of integers, we have to find the number of non-empty continuous subarrays that satisfy this condition: The leftmost element of the subarray is not larger than other elements in the subarray.So, if the input is like [1, 4, 2, 5, 3], then the output will be 11, as there are 11 valid subarrays, they are like [1], [4], [2], [5], [3], [1, 4], [2, 5], [1, 4, 2], [2, 5, 3], [1, 4, 2, 5], [1, 4, 2, 5, 3].To solve this, we will follow these steps −ret := 0n := size of numsDefine ... Read More

1K+ Views
Suppose we have one horizontal number line. On that number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = size of the stations array. Now, we add K more gas stations so that D, the maximum distance between adjacent gas stations, is minimized. We have to find the smallest possible value of D.So, if the input is like stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], K = 9, then the output will be 0.5To solve this, we will follow these steps −Define a function ok(), this will take x, array ... Read More

834 Views
Suppose we have a simple expression string and we have to Implement a basic calculator to evaluate that expression. The expression string may contain opening and closing parentheses, the plus + or minus sign -, non-negative integers and empty spaces. The expression string contains only non-negative integers, +, -, *, / operators, opening and closing parentheses and empty spaces. The integer division should truncate toward zero.So, if the input is like "6-4 / 2", then the output will be 4To solve this, we will follow these steps −l1 := 0, l2 := 1o1 := 1, o2 := 1Define one stack ... Read More

546 Views
Suppose we have given a list of schedules of employees; this represents the working time for each employee. Now suppose each employee has a list of non-overlapping Intervals, these intervals are sorted. We have to find the list of finite intervals representing the common, positive-length free time for all employees, and that will also be in sorted order. We are representing Intervals in the form [x, y], For example, schedule [0][0].start = 1, schedule[0][0].end = 2.So, if the input is like schedule = [[[1, 2], [5, 6]], [[1, 3]], [[4, 10]]], then one of the output will be [[3, 4]].To ... Read More

1K+ Views
Suppose we have two strings S and T, we have to find the minimum substring W of S, so that T is a subsequence of W. If there is no such window in S that covers all characters in T, then return empty string. If there are multiple such windows, we have to return the one with the left-most starting index.So, if the input is like S = "abcdebdde", T = "bde", then the output will be "bcde" as it occurs before "bdde". "deb" is not a smaller window because the elements of T in the window must occur in ... Read More

467 Views
Suppose we have a non-empty 2D binary array called grid, here an island is a group of 1's (representing land) connected 4-directionally. We can also assume all four edges of the grid are surrounded by water.We have to count the number of distinct islands. An island is considered to be the same as another if they have the same shape, or have the same shape after rotation of 90, 180, or 270 degrees only or reflection of left/right direction or up/down direction.So, if the input is like, 11000100000000100011then the output will be 1To solve this, we will follow these steps ... Read More

387 Views
Suppose we have N bulbs in a row and they are numbered from 1 to N. At first, all the bulbs are off. We can turn on exactly one bulb everyday until all bulbs are on after N days. If we have an array bulbs of length N where bulbs[i] = x this indicates that on the (i+1)th day, we will turn on the bulb at position x. If we have another integer K, such that out the minimum day number such that there exists two turned on bulbs that have exactly K bulbs between them that are all off. ... Read More