
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

724 Views
In this article, we will understand how to print star Pascal’s triangle in Java. The Pascal’s triangle is formed by using multiple for-loops and print statements. All values outside the triangle are considered zero (0). The first row is 0 1 0 whereas only 1 acquire a space in Pascal’s triangle, 0s are invisible. The second row is acquired by adding (0+1) and (1+0). The output is sandwiched between two zeroes. The process continues till the required level is achieved. Problem Statement Write a program in Java to print star Pascal's triangle. Below is a demonstration of the same − ... Read More

1K+ Views
Suppose, we are given 2n number of coordinates on a two-dimensional plane. The 2n coordinates are divided into two arrays coordA, and coordB. The coordinates are represented as integer pairs. Now we have to form coordinate pairs that will contain one point from coordA and one point from coordB. We can make pairs if and only if the x coordinate of the point from coordA is smaller than that of the point from coordB, and the y coordinate of the point from coordA is smaller than that of the point from coordB. We have to find out the number of ... Read More

877 Views
In this article, we will understand how to print a downward triangle star pattern using Java. In this pattern, the face of the triangle will be in a downward direction, and the base will be in an upward direction. We will learn through two examples: one where the user inputs the number of rows, and another where the number of rows is predefined in the program. Problem Statement Write a Java program to print a downward triangle star pattern. Below is a demonstration of the same. Input: Enter the number of rows : 8 Output: The downward triangle star pattern ... Read More

252 Views
Suppose, we are given a minimally connected graph. That means removing any edge will make the graph disconnected. The graph has n vertices and the edges are given in an array 'edges'. There is also an array 'vertexValues' given to us that contain n integer values.Now, we do the following −We write a positive integer on each of the vertices and then try to calculate a score.There is an edge connecting two vertices, we put the smaller value of the two vertices on the edges.We calculate the score by adding all the edge values.We have to find the maximum value ... Read More

493 Views
In this article, we will understand how to print mirror upper star triangle pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The mirror upper star pattern : ******** ******* ****** ***** **** *** ** *AlgorithmStep 1 - START Step 2 - Declare four integer values namely i, ... Read More

997 Views
In this article, we will learn to print the upper star triangle pattern in Java. Printing patterns is a common exercise to strengthen the understanding of loops in programming. One of the most popular patterns is the Upper Star Triangle, which visually resembles an inverted right-angled triangle of stars aligned from the top. Below is a demonstration of the same − Input Enter the number of rows : 8 Output The upper star triangle star pattern : * ... Read More

265 Views
Suppose, we are given n three-dimensional coordinates. The cost to travel from coordinate (a, b, c) to (x, y, z) is ∣ x − a∣ + ∣ y − b∣ + max(0, z − c). We start from the first coordinate, then visit all the coordinates at least once, and then return to the first coordinate. We have to find out the total cost of this whole trip. The coordinates are given to us in the array 'coords'.So, if the input is like n = 3, coords = {{1, 1, 0}, {1, 3, 4}, {3, 2, 2}}, then the output ... Read More

256 Views
Suppose, we have a grid of dimensions h x w. The grid is represented in a 2D array called ‘initGrid’, where each cell in the grid is either represented by a '#' or a '.'. '#' means that the grid contains an obstacle and '.' means that there is a path through that cell. Now, a robot is placed on a cell 'c' on the grid having row number x and column number y. The robot has to travel to another cell 'd' having row number p and column number q. Both the cell coordinates c and d are presented ... Read More

193 Views
Suppose, we have a n x n matrix. Each element in the matrix is unique and is an integer number between 1 and n2. Now we can perform the operations below in any amount and any order.We pick any two integers x and y that are in the matrix, where (1 ≤ x < y ≤ n) and swap the columns containing x and y.We pick any two integers x and y that are in the matrix, where (1 ≤ x < y ≤ n) and swap the rows containing x and y.We have to note that x + y ... Read More

197 Views
Suppose, we are given a grid of dimensions h x w. Each cell in the grid contains some positive integer number. Now there is a path-finding robot placed on a particular cell (p, q) (where p is the row number and q is the column number of a cell) and it can be moved to cell (i, j). A move operation has a particular cost, which is equal to |p - i| + |q - j|. Now there are q number of trips, which has the following properties.Each trip has two values (x, y) and there is a common value ... Read More