
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

3K+ Views
Linear Search on a Java Array using RecursivelyLinear search is an algorithm that we use to check if an element is present in an array or not. It checks all the elements of the array one by one until it finds the element or reaches the end of the array. Recursion is a way where a function calls itself to solve a certain problem until it reaches a base case. In this article, we will understand how to recursively linearly search an element in an array. Let's see an example: Input: int [] arr = {1, 2, 3, 4, 5}; ... Read More

1K+ Views
In this article, we will understand how to multiply two matrices using multi-dimensional arrays in Java. The matrix has a row and column arrangement of its elements. A matrix with m rows and n columns can be called as m × n matrix. Individual entries in the matrix are called elements and can be represented by a[i][j] which suggests that the element a is present in the ith row and jth column. Problem Statement Write a program in Java to multiply two matrices using multi-dimensional arrays. Below is a demonstration of the same − Input First matrix: 2 3 4 ... Read More

1K+ Views
For two given matrices, each of size m x n, we need to write a Java program to add them. Amatrix has a row and column arrangement of its elements. A matrix with m rows and n columns can be called as m x n matrix. Individual entries in the matrix are called elements and can be represented by a[i][j], which means that the element a is present at the ith row and jth column. Matrix is an example of multi-dimensional array. In Java, a multi-dimensional array is an array of arrays. It is used to store data within a ... Read More

311 Views
In this article, we will understand how to interchange the diagonal elements of a given matrix in Java. A matrix is a two-dimensional array made up of rows and columns. A matrix with m rows and n columns is called an m × n matrix. Each element in the matrix is represented by a[i][j], which means that the particular element a is present in the i-th row and j-th column. Problem Statement Write a Java program to interchange the elements of the primary and secondary diagonals of a square matrix. Example Scenario ... Read More

284 Views
Suppose we have a string S with n characters. The characters will be either '+' or '-'. There is a pile of stones, n times we either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile. We have to find the minimal possible number of stones that can be in the pile after making these operations. If we took the stone on i-th operation, S[i] is equal to "-", if added, S[i] is equal to "+".So, if the input is like S ... Read More

302 Views
Suppose we have a string S of size n and another number k. The string contains four types of characters. Consider there are few cells, a grasshopper wants to jump to reach the target. Character '.' means that the corresponding cell is empty, character '#' means that the corresponding cell contains an obstacle and grasshopper can't jump there. 'G' means that the grasshopper starts at this position and, 'T' means that the target cell. The grasshopper is able to jump exactly k cells away from its current position. We have to check whether the grasshopper can jump to the target ... Read More

12K+ Views
In this article, we will understand how to compute the sum of diagonals of a matrix. The matrix has a row and column arrangement of its elements. The principal diagonal is a diagonal in a square matrix that goes from the upper left corner to the lower right corner.The secondary diagonal is a diagonal of a square matrix that goes from the lower left corner to the upper right corner.Below is a demonstration of the same −Suppose our input is −The input matrix: 4 5 6 7 1 7 3 4 11 12 13 14 23 24 25 50The desired ... Read More

281 Views
Suppose we have an array A with n elements. We need to paint elements in colors such that −If we consider any color, all elements of this color must be divisible by the minimal element of the same color.The number of used colors should be minimized.We have to find the minimum number of colors to paint all the given numbers in a valid way.So, if the input is like A = [10, 2, 3, 5, 4, 2], then the output will be 3, because paint the first color to the elements A[0] and A[3], paint second color to the elements ... Read More

170 Views
Suppose we have five numbers in an array T. There are five cards and each card has a number written on them. The ith card has T[i] written on it. We can discard some cards and our goal is to minimize the sum of numbers written on remaining numbers. He is allowed to at most once discard two or three cards with the same number. We won't discard cards if it's impossible to choose two or three cards with the same number. We have to find the minimum sum possible.So, if the input is like T = [7, 3, 7, ... Read More

335 Views
Suppose, we are given two points a = (x1, y1) and b = (x2, y2). The Manhattan distance between two points is dist(a, b) = |x1 - x2| + |y1 - y2|. If the point a's coordinate is (0, 0) and the point b's coordinate is (x, y), we have to find a point c such that dist(a, c) = dist(a, b)/ 2 and dist(b, c) = dist(a, b)/2. If a point like that is not available then, we print -1, -1.So, if the input is like x = 13, y = 7, then the output will be 6, 4.StepsTo ... Read More