
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
In this article, we will learn to create pyramid patterns using Java. It will help us to understand how loops work. for loop while loop Java program to create pyramid patterns We are going to print the following pyramid patterns: Half Star Pyramid Inverted Half Star Pyramid Star Pyramid Inverted Star Pyramid Numeric Pyramid Pattern 1: Half Star Pyramid We will initialize the row to 5 and a loop runs from i-1 to i

174 Views
Suppose we have an array A with N elements. Consider there are N boxes and they are arranged in a circle. The ith box contains A[i] stones. We have to check whether we can remove all stones from the boxes by repeatedly performing the operation: Select a box say ith box. For each j in range 1 to N, remove exactly j stones from the (i+j)th box. Here (N+k)th box is termed as kth box. This operation cannot be performed if a box does not contain sufficient number of stones.So, if the input is like A = [4, 5, 1, ... Read More

154 Views
Suppose we have a list of numbers A with N elements in it. The elements are 1, 2 or 3, Consider a number X[1][j] = A[j] where j is in range 1 to N. And X[i][j] = |X[i-1][j] - X[i-1][j+1]| where i is in range 2 to N and j is in range 1 to N+1-i. We have to find the value of X[i][j].So, if the input is like A = [1, 2, 3, 1], then the output will be 1, becauseX[1][1] to X[1][4] are 1, 2, 3, 1 X[2][1], X[2][2], X[2][3] are |1-2| = 1, |2 - 3| = ... Read More

6K+ Views
In this article, we will understand how to print pyramid star 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 pyramid star pattern : * * * * * * * * * * * * * * * * * * * * * * * ... Read More

12K+ Views
In this article, we will understand how to print square star 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 length of a side : 8OutputThe desired output would be −The square pattern : * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ... Read More

154 Views
Suppose we have a string S with possible characters '0', '1' or '?'. We want to make string T by replacing each occurrence of '?' with 0 or 1. The unbalancedness of T is like: maximum of the all absolute differences between number of occurrences of 0 and 1 in between lth and rth character in S where 0 1; if (check(S, Mid)) R = Mid - 1; else L = Mid + 1; } return R + 1; } int main() { string S = "0??0"; cout

156 Views
Suppose, there is a manufacturer that makes specific parts for a particular product. The manufacturer has n different variations of the parts, and the parts have a specific rating on three criteria. The ratings of the n products are given in the array 'ratings' where each element is of the format (A, B, C) where A, B, and C are different rating criteria of the product. Now, an OEM wants to buy m parts for each product they make from the manufacturer of the parts. The OEM chooses the parts satisfying the below conditions −Two or more units of the ... Read More

1K+ Views
In this article, we will understand how to print the Diamond Star pattern using Java. The pattern is formed by using multiple for-loops and print statements. Output Below is the demonstration of the diamond star pattern − The diamond star pattern : * *** ***** ******* ********* *********** ************* *************** ************* *********** ********* ******* ***** ... Read More

533 Views
Suppose, there are n cities and m roads are connecting them. Each road is unidirectional, and it takes a particular amount of time to reach from the source city to the destination city. The information of the roads is given in the array roads where each element is of the format (source, destination, time). Now, a person is traveling from one city to another city and the trip has to be a round-trip. A trip can be called round-trip when the person starts from a particular city, goes through one or more roads, and finishes the trip in the same ... Read More

198 Views
Suppose, we have a permutation of integers 'seq' and an array of integer pairs 'pairs' of size m that contains integers 0 to n - 1. Now, we perform the following operation on seq as many times as possible so that seq[i] = i (0 ≤ i < n) is maximized.We have to choose an integer j where 0