Find Maximum Value of i in C++ Program

Arnab Chakraborty
Updated on 25-Feb-2022 11:41:05

199 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

Find Number of Coordinate Pairs in C++

Arnab Chakraborty
Updated on 25-Feb-2022 11:29:45

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

Find Maximum Sum of a Minimally Connected Graph in C++

Arnab Chakraborty
Updated on 25-Feb-2022 11:18:57

253 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

Print Mirror Upper Star Triangle Pattern in Java

AmitDiwan
Updated on 25-Feb-2022 11:10:15

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

Calculate Cost to Travel Given Coordinates in C++

Arnab Chakraborty
Updated on 25-Feb-2022 11:07:24

266 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

Find Number of Jumps for Robot to Reach Cell in Grid

Arnab Chakraborty
Updated on 25-Feb-2022 10:46:30

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

Volume of Conductor Material in Underground Two-Phase AC System

Manish Kumar Saini
Updated on 25-Feb-2022 10:37:24

566 Views

When the two-phase AC electrical power is transmitted through the underground cables from the generating station to the consumers, then the transmission system is called the underground two-phase AC system of transmission.Depending upon the number of conductors used, the underground two-phase AC system is classified into two types viz −Two-phase three-Wire AC SystemTwo-phase four-wire AC SystemConductor Material Required in Underground Two-Phase Three-Wire AC SystemFigure-1 shows the circuit diagram of the underground two-phase three-wire AC system of electric power transmission.Let us consider that the maximum voltage between the outer conductors is $\mathit{V_{\mathit{m}}}$. Then, the maximum voltage between any one outer wire ... Read More

Volume of Conductor Material Required in Underground Three-Phase AC System

Manish Kumar Saini
Updated on 25-Feb-2022 10:34:39

984 Views

Underground Three Phase AC SystemWhen the three phase AC electric power is transmitted through the underground cables, then the system of electric power transmission is called the underground three phase AC system.Depending upon the number of conductors used, the underground three-phase AC system of electric power transmission is classified into two types −Three-Phase Three-Wire SystemThree-Phase Four-Wire SystemConductor Material Required in Underground Three-Phase Three-Wire SystemThe circuit diagram of the underground 3-phase 3-wire AC system is shown in Figure-1. In this system, the three line conductors are taken from the three phase windings of the alternator.Let the maximum value of voltage between ... Read More

Unique Matrices from Swapping Rows and Columns in C++

Arnab Chakraborty
Updated on 25-Feb-2022 10:31:41

194 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

Volume of Conductor Material for Underground Single Phase AC System

Manish Kumar Saini
Updated on 25-Feb-2022 10:26:59

619 Views

Underground Single-Phase AC SystemThe electric transmission system which transmits the single-phase AC electric power through the underground cables is termed as the underground single-phase AC system of transmission.The underground single-phase AC system of electric power transmission is classified into three types viz. −Single-Phase Two-Wire AC SystemSingle-Phase Two-Wire AC System with Mid-Point EarthedSingle-Phase Three-Wire AC SystemThe various systems of the electric transmission require different volume of conductor material. The volume of conductor material required in the above 1-phase underground AC system is described below.Conductor Material Required in 1-Phase 2-Wire Underground AC SystemThe typical single-phase 2-wire AC underground AC system is shown ... Read More

Advertisements