
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

301 Views
Suppose we have a grid arr, this is a square grid, a falling path with non-zero shifts is a choice of exactly one element from each row of arr, such that no two elements chosen in adjacent rows are present in the same column. We have to find the minimum sum of a falling path with nonzero shifts.So, if the input is like arr is like [[1, 2, 3], [4, 5, 6], [7, 8, 9]], then the output will be 13, as there are different falling paths, these are like [1, 5, 9], [1, 5, 7], [1, 6, 7], [1, ... Read More

274 Views
Suppose there is an array of size arrLen, and we also have a pointer at index 0 in that array. At each step, we can move 1 position to the left, 1 position to the right in the array or stay in the same place.Now suppose we have two integers steps and arrLen, we have to find the number of ways such that the pointer still at index 0 after exactly steps. If the answer is very large then return it modulo 10^9 + 7.So, if the input is like steps = 3, arrLen = 2, then the output will ... Read More

218 Views
Suppose there is a puzzle string, a word is valid if both the following conditions valid −word contains the first letter of puzzle.For each letter in word, that letter is in puzzle.Suppose if we consider an example that, if the puzzle is like "abcdefg", then valid words are "face", "cabbage" etc; but some invalid words are "beefed" as there is no "a" and "based" as there is "s" which is not present in the puzzle.We have to find the list of answers, where answer[i] is the number of words in the given word list words that are valid with respect ... Read More

510 Views
Suppose there is a binary tree. We will run a preorder depth first search on the root of a binary tree.At each node in this traversal, the output will be D number of dashes (Here D is the depth of this node), after that we display the value of this node. As we know if the depth of a node is D, the depth of its immediate child is D+1 and the depth of the root node is 0.Another thing we have to keep in mind that if a node has only one child, that child is guaranteed to be ... Read More

251 Views
Suppose we have one 2-dimensional grid, there are 4 types of squares −In a square 1 is for the starting point. There will be exactly one starting square.In a square 2 is for the ending point. There will be exactly one ending square.In a square 0 is for the empty squares and we can walk over.In a square -1 if for the obstacles that we cannot walk over.We have to find the number of 4-directional walks from the starting square to the ending square, that walk over every non-obstacle square exactly once.So, if the input is like −10000000102-1then the output ... Read More

616 Views
Suppose we have an array A. From some starting index, we can make a series of jumps. The position (1, 3, 5, ...) jumps in the series are called odd numbered jumps, and position (2, 4, 6, ...) jumps in the series are called even numbered jumps.Now we may from index i jump forward to index j (with i < j) in this way −During odd numbered jumps, we can jump to the index j such that A[i] = A[j] and A[j] is the largest possible value. When there are multiple such indexes j, we can only jump to the ... Read More

14K+ Views
In this problem, we are given an array arr[] of n integers. Our task is to create a program to find the minimum and maximum element of an array in C++.Problem Description − Here, we have an array arr[]. The contains n integer values. We have to find the maximum value and minimum value out of all values of the array.Let’s take an example to understand the problem, Inputarr[] = {2, 1, 6, 9, 4, 10, 15, 21}Outputmax = 21 , min = 1Solution ApproachThere can be multiple solutions to the problem, One solution would be directly comparing elements of ... Read More

1K+ Views
In this problem, we are given two points A and B, starting and ending point of a line. Our task is to create a program to find the mid-point of a line in C++.Problem Description − Here, we have a line with starting and ending points A(x1, y1) and B(x2, y2). And we need to find the mid-point of the line.Let’s take an example to understand the problem, Inputa(x1, y1) = (4, -5) b(x2, y2) = (-2, 6)Output(1, 0.5)Explanation(x1 + x2)/2 = 4 - 2 / 2 = 1 (y1 + y2)/2 = -5 + 6 / 2 = 0.5Solution ... Read More

260 Views
Suppose we have a binary tree; we place cameras on the nodes of the tree. Now each camera at a node can monitor its parent, itself, and its children. We have to find the minimum number of cameras needed to monitor all nodes of the tree.So, if the input is like −then the output will be 1, because only one camera is enough to track all.To solve this, we will follow these steps −Define one set called covered, of type TreeNode (Tree node has left, right and data field)Define a function solve(), this will take node, parent, if node is ... Read More

384 Views
In this problem, we are given an array arr[] consisting of n integers. Our task is to create a program to find the maximum difference between the index of any two different numbers in C++.Code Description − Here, we need to find the maximum difference between the index of integer values of the array, given that the two integers are different.Let’s take an example to understand the problem, Inputarr[] = {4, 1, 3, 2, 1, 2, 4}Output5ExplanationThe difference between index 0, element 4, and index 5, element 2.Solution ApproachWe will try to find the maximum possible difference between the index ... Read More