
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 33676 Articles for Programming

1K+ Views
Suppose we have two strings str1 and str2. And their lengths are same, we have to check whether we can transform str1 into str2 by doing zero or more conversions.In one conversion we can convert all occurrences of one character in str1 to any other lowercase English character. We have to check whether we can transform str1 into str2 or not.So, if the input is like str1 = "aabcc", str2 = "ccdee", then the output will be true, as Convert 'c' to 'e' then 'b' to 'd' then 'a' to 'c'. Here we have to keep in mind that the ... Read More

252 Views
Suppose there are N courses, and these are labelled from 1 to N. We also gave a relation array, where relations[i] = [X, Y], is representing a prerequisite relationship between course X and course Y. So, this means course X has to be studied before course Y.In one semester we can study any number of courses as long as we have studied all the prerequisites for the course we are studying. We have to find the minimum number of semesters needed to study all courses. And if there is no way to study all the courses, then return -1.So, if ... Read More

242 Views
Suppose we have a non-decreasing array of positive integers called nums and an integer K, we have to find out if this array can be divided into one or more number of disjoint increasing subsequences of length at least K.So, if the input is like nums = [1, 2, 2, 3, 3, 4, 4], K = 3, then the output will be true, as this array can be divided into the two subsequences like [1, 2, 3, 4] and [2, 3, 4] with lengths at least 3 each.To solve this, we will follow these steps −d := a new mapreq ... Read More

881 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

835 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

547 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