Given area of square inscribed in a circle as N, the task is to calculate the area of circle in which the square is inscribed.Examples: Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your […]

Continue Readingclass Node: def __init__(self, val): self.data = val self.next = None self.prev = None self.top = None self.bottom = None class LinkedList: def __init__(self): self.head = None def Quad(self, grid, n, m): self.head = Node(grid[0][0]) temp = self.head i = 0 j = 1 while temp.top != self.head: if j < m and i == 0: temp.next = Node(grid[i][j]) temp = temp.next j += 1 elif j == m and i < n - 1: i […]

Continue ReadingGiven the length of the three semi-axes as A, B, and C, the task is to find the surface area of the given Ellipsoid.Ellipsoid is a closed surface of which all plane cross-sections are either ellipses or circles. An ellipsoid is symmetrical about the three mutually perpendicular axes that intersect at the center. It is […]

Continue Reading#include using namespace std; vector calculateDivisors(int N){ vector div; for (int i = 1; i * i A[i].second) { swap(A[i].first, A[i].second); } st.insert(A[i]); } vector div = calculateDivisors(N); for (auto x : div) { bool exist = 1; for (int i = 0; i < M; i++) { int dx = (A[i].first + x) % N; int dy = (A[i].second + x) % N; if (dx > dy) { swap(dx, […]

Continue ReadingGiven a rectangle of length L and breadth B, the task is to print the maximum integer altitude possible of the largest triangle that can be inscribed in it, such that the altitude of the triangle should be equal to half of the base.Examples:Input: L = 3, B = 4Output: 2Input: L = 8, B […]

Continue ReadingGiven N horizontal lines represented by an array position[][] of size N, where position[i] represents the ith horizontal line which has x-coordinates from position[i][0] to position[i][1] and an integer K, which represents the maximum number of vertical lines that can be drawn, the task is to check if N given lines can be intersected by […]

Continue ReadingGiven two positive integers h and w representing the height h and width w which forms a rectangle. Also, there are two arrays of integers horizontalCuts and verticalCuts where horizontalCuts[i] is the distance from the top of the rectangle to the ith horizontal cut and similarly, verticalCuts[j] is the distance from the left of the […]

Continue ReadingArea of a triangle with two vertices at midpoints of opposite sides of a square and the other vertex lying on vertex of a squareGiven a positive integer N representing the side of a square, the task is to find the area of a triangle formed by connecting the midpoints of two adjacent sides and […]

Continue Reading#include using namespace std; void check_position(int a, int b, int c, int d, int x1, int y1, int z1, int x2, int y2, int z2){ int value_1 = a * x1 + b * y1 + c * z1 + d; int value_2 = a * x2 + b * y2 + c * z2 + d; if ((value_1 > 0 […]

Continue Reading#include using namespace std; double radius(int a, int b, int c){ int g = a / 2; int f = b / 2; if (g * g + f * f – c < 0) return (-1); return (sqrt(g * g + f * f - c));} double centerDistanceFromLine(int a, int b, int i, int j, int k){ int g = a / 2; int f […]

Continue Reading