Spoj ACPC10A solution

Spoj ACPC10A solution. Spoj Whats Next solution. Category: AdHoc, Math, Formula This question is based on direct application of Arithmetic Progression‘s common difference and Geometric Progression‘ common ratio. First check whether there is a common difference (c-b) and (b-a) , or whether there is common ratio (c/b) and (b/a). Spoj ACPC10A solution code: #include <bits/stdc++.h> using… Read More »

Spoj PRISMSA solution

Spoj PRISMSA solution. Spoj TRIANGULAR PRISM solution. Category: AdHoc, Math, Formula This question is of minimization of Surface Area for a Triangular Prism whose volume is given. Applying the standard differentiating procedure, the value of “a” comes out to be: a = (4V)1/3  , h = a/ sqrt(3) Putting the values together, we get: Surface Area = 3*a*a*sqrt(3) / 2;… Read More »

Spoj TETRA solution

Spoj TETRA solution. Spoj Sphere in a tetrahedron  solution. Category: AdHoc, Geometry, Formula This question is based on geometry as we need to find the radius of the sphere subscribed inside an irregular tetrahedron Required Radius = (3*volume of Tetrahedron)/(sum of surface areas of triangular faces). This requires calculation of volume of Irregular Tetrahedron using its edge… Read More »

Spoj PIR solution

Spoj PIR solution. Spoj Pyramids solution. Category: AdHoc, Geometry, Formula This question is based on geometry as we need to find the volume of Irregular Tetrahedron using its edge lengths. Here is the formula required: Spoj Pyramids solution code: #include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); int t; cin>>t; while(t–) { double u,v,w,U,V,W,vol,a,b=12; cin>>u>>v>>w>>W>>V>>U; /*steps to calculate volume… Read More »

Find minimum number of merge operations to make an array palindrome

Find minimum number of merge operations to make an array palindrome In this post we try to convert a given array into a palindrome by using minimum number of merge operations. Find minimum number of merge operations to make an array palindrome Given an array of positive integers. We need to make the given array… Read More »

Group even and odd numbers in a linked list

Group even and odd numbers in a linked list Problem statement for segregating even and odd numbers in a linked list: Given a singly linked list, you have to group the even numbers and the odd numbers. The even numbers’ group must be ahead the group of odd numbers. Also, each number in the groups… Read More »

Binary Search Trees from keys 1 to n

Construct Binary Search Trees from keys 1 to n Problem statement to construct a Binary Search Tree(BST) from keys 1 to n. We are given a list of consecutive numbers from 1 to . Determine the number of binary trees that can be constructed from these numbers. Example for building a Binary Search Tree from keys… Read More »

Find position of an element in a sorted array of infinite numbers

Find position of an element in a sorted array of infinite numbers In this post we deal with the problem of finding position of an element in a given array which is sorted and has infinite numbers. Find position of an element in a sorted array of infinite numbers Problem Statement Given a sorted array… Read More »

Arrange elements of given array to form largest number

Arrange elements of given array to form largest number In this post we learn how to form the largest number from all the given elements of the input array. Arrange elements of given array to form largest number Problem Statement: Given an array of numbers,we need to arrange them in a way that yields the… Read More »

Rearrange Positive and Negative numbers in an array

Rearrange Positive and Negative numbers in an array In this post we solve the problem of rearranging positive and negative elements of an array such that they are placed alternatively in the same array. Rearrange Positive and Negative numbers in an array Problem Statement Given array contains both positive and negative numbers in random order.… Read More »