
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

879 Views
Suppose we have a n x n matrix represents a chess board. There are some 1s and 0s, where 1 represents a queen and 0 represents an empty cell. We have to check whether the board is valid solution to the N-Queen puzzle or not. As we know a board is a solution of valid N-queen solution where no two queens are attacking each other.So, if the input is likethen the output will be TrueTo solve this, we will follow these steps:n := row count of matrixrows := a new set, cols := a new set, diags := a new ... Read More

287 Views
Suppose we have a list of lists called rooms. Each index i in rooms represents a room and rooms[i] represents different keys to open other rooms. The room 0 is open and we are at that room and every other room is locked. We can move freely between opened rooms; we have to check whether we can open every room or not.So, if the input is like rooms = [[2, 0], [3], [1], []], then the output will be True, as we start from room 0 and can go to room 2 with its key 2. From room 2 we ... Read More

330 Views
Suppose we have a number n; we have to find the nth ugly number. As we know that the ugly numbers are those numbers, whose prime factors are only 2, 3 and 5. So if we want to find 10th ugly number, the output will be 12, as the first few ugly numbers are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 and so on.To solve this, we will follow these steps:Define an array v of size(n + 1)if n is same as 1, then:return 1two := 2, three := 3, five := 5twoIdx := 2, threeIdx := 2, fiveIdx := 2for initialize i := 2, when i

211 Views
Suppose we have two sorted lists. We have to find the median of these two lists. So if the arrays are like [1,5,8] and [2,3,6,9], then the answer will be 5.To solve this, we will follow these steps:Define a function solve(), this will take an array nums1, an array nums2,if size of nums1 > size of nums2, then:return solve(nums2, nums1)x := size of nums1, y := size of nums2low := 0, high := xtotalLength := x + ywhile low

389 Views
Suppose we have a list of numbers called nums. And it is representing the height of square blocks, we have to check whether the shape is symmetric over the y = x line or not.So, if the input is like nums = [7, 5, 3, 2, 2, 1, 1], then the output will be TrueTo solve this, we will follow these steps:i := 0j := size of nums - 1while i

357 Views
Suppose we have a number n, we have to find the number of lists of positive consecutive values that sum up to n.So, if the input is like n = 15, then the output will be 4, as The possible lists are: [1, 2, 3, 4, 5], [4, 5, 6], [7, 8], and [15].To solve this, we will follow these steps:begin := 1, end := 1, x := (n + 1)sum := 0while end = n, do:if sum is same as n, then:(increase count by 1)sum := sum - begin(increase begin by 1)(increase end by 1)return count + 1Let us ... Read More

178 Views
Suppose we have four list of numbers A, B, C and D and also have another number target. We have to find the number of different unique indices i, j, k, l such that A[i] + B[j] + C[k] + D[l] ≤ target.So, if the input is like A = [3, 2] B = [5, 3] C = [1] D = [2, 3] target = 9, then the output will be 3, as We can pick the following combinations: [3, 3, 1, 2] [3, 3, 1, 2] [2, 3, 1, 3]To solve this, we will follow these steps:temp_list := a ... Read More

2K+ Views
Suppose we have a 2D matrix mat. We have to print the matrix elements in a spiral way. At first starting from the first row (mat[0, 0]), print the whole content and then follow the last column to print, then the last row, and so on, thus it prints the elements in a spiral fashion.So, if the input is like71092916239142759911then the output will be [7, 10, 9, 1, 3, 4, 5, 11, 9, 9, 2, 9, 6, 2, 9, 2, 1, 7]To solve this, we will follow these steps:d := 0top := 0, down := row count of matrix – 1, left := 0, right := column count of matrix - 1c := 0res := a new listdirection := 0while top

5K+ Views
Suppose we have a linked list. We have to sort the list into ascending order.So, if the input is like [5, 8, 4, 1, 5, 6, 3], then the output will be [1, 3, 4, 5, 5, 6, 8, ]To solve this, we will follow these steps:values := a new listhead := nodewhile node is not null, doinsert value of node at the end of valuesnode := next of nodesort the list valuesvalues := make a double ended queue by taking elements of valuesnode := headwhile node is not null, dovalue of node := left element of queue and delete ... Read More

3K+ Views
Suppose we have a list of numbers called items and another value n. A salesman has items in a bag with random IDs. The salesman can delete as many as n items from the bag. We have to find the minimum number of different IDs in the bag after n removals.So, if the input is like items = [2, 2, 6, 6] n = 2, then the output will be 1 as we he can sell two items with ID 2 or ID 6, then only items with single target will be there.To solve this, we will follow these steps:c ... Read More