
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

277 Views
Suppose we have a graph, represented as a list of edges. We have to check whether the graph is a collection of trees (forest) or not.So, if the input is likethen the output will be TrueTo solve this, we will follow these steps −Define a function dfs() . This will take node, previf node in seen, thenreturn Falseinsert node into seenfor each adjacent node n in e[node], doif n is not same as prev, thenif dfs(n, node) is false, thenreturn Falsereturn TrueFrom the main method, do the following −e := an empty mapfor each start node u and end node ... Read More

215 Views
Suppose we have a list of airline tickets represented by pairs of departure and arrival airports like [from, to], we have to reconstruct the itinerary in correct order. All of the tickets belong to a man who departs from KLK. So, the itinerary must begin with JFK.So if the input is like [["MUC", "LHR"], ["KLK ", "MUC"], ["SFO", "SJC"], ["LHR", "SFO"]], then the output will be ["KLK ", "MUC", "LHR", "SFO", "SJC"].To solve this, we will follow these steps −Define array ret and a map called graph.Define a method called visit. This will take airport name as inputwhile size of ... Read More

346 Views
Suppose we have a list of sorted list of distinct integers of size n, we have to find the first positive number in range [1 to n+1] that is not present in the array.So, if the input is like nums = [0, 5, 1], then the output will be 2, as 2 is the first missing number in range 1 to 5.To solve this, we will follow these steps −target := 1for each i in arr, doif i is same as target, thentarget := target + 1return targetLet us see the following implementation to get better understanding −Example Live Democlass Solution: ... Read More

191 Views
Suppose we have a list of numbers called nums, we have to find the first missing positive number. In other words, the lowest positive number that does not present in the array. The array can contain duplicates and negative numbers as well.So, if the input is like nums = [0, 3, 1], then the output will be 2To solve this, we will follow these steps −nums := a set with all positive numbers present in numsif nums is null, thenreturn 1for i in range 1 to size of nums + 2, doif i is not present in nums, thenreturn iLet ... Read More

123 Views
Suppose there is an array, and that is sorted, consider that array is rotated at some pivot, that is unknown to us. So we have to find the maximum from that rotated array. So if the array is like[3, 4, 5, 1, 2], then the output will be 5.To solve this, we will follow these steps −low := 0 and high := last index of array, n := size of array, ans := 0while low arr[mid], then ans := maximum of ans and arr[mid], high := mid – 1else if low = mid, then ans := maximum of ans ... Read More

376 Views
Suppose we have given a list of numbers called ratings, and this is showing the performance scores of coders. Now the manager wants to give Rs 1000 to every coder except if two coders are adjacent, they would like to pay the better performing coder at least Rs 1000 higher than the worse performing one. We have to find the minimum amount the manager can pay following above constraints.So, if the input is like ratings = [1, 2, 5, 1], then the output will be 7000, as the minimum we can pay for each respective coder is [1000, 2000, 3000, ... Read More

236 Views
Suppose we have a positive number n, we have to check whether n can be written as the sum of unique positive factorial numbers or not.So, if the input is like n = 144, then the output will be True, as 4! + 5! = 24 + 120 = 144To solve this, we will follow these steps −fact := 1res := a new listx := 2while fact = res[i], thenn := n - res[i]return true when n is same as 0Let us see the following implementation to get better understanding −Example Live Democlass Solution: def solve(self, n): fact = 1 ... Read More

593 Views
Suppose we have two values 0 and 1 then how many combinations of these values are possible, the answer is 8 and these combinations are (0,0), (1,0), (0,1), (1,1). In R, we can use expand.grid function to create these combinations but to save it in a data frame, we would need to use as.data.frame function.Example Live Demodf1

411 Views
A standard normal distribution has mean equals to zero and the standard deviation equals to one. Therefore, when we plot it with three sigma limits, we have six points on the X-axis referring to the plus and minus around zero. If the limits are defined then the plotting can be shown with larger width and that will change the display of the curve. We can do this by creating a sequence for the length of the standard normal variable and its density.Consider the below vectors corresponding to the limits and density−x

3K+ Views
The correlation coefficient value size in correlation matrix plot created by using corrplot function ranges from 0 to 1, 0 referring to the smallest and 1 referring to the largest, by default it is 1. To change this size, we need to use number.cex argument. For example, if we want to decrease the size to half then we can use number.cex = 0.5.ExampleConsider the below matrix − Live Demoset.seed(99) M corrplot(cor(M), addCoef.col="black")OutputChanging the size of correlation coefficient value to 0.75 −corrplot(cor(M), addCoef.col="black", number.cex=0.75)OutputChanging the size of correlation coefficient value to 0.30 −> corrplot(cor(M), addCoef.col="black", number.cex=0.30)OutputRead More