class 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 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 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 ReadingSize of smallest square that contains N non-overlapping rectangles of given dimensions Given two positive integers W and H and N rectangles of dimension W*H, the task is to find the smallest size of the square required such that all the N rectangles can be packed without overlapping. Examples:Input: N = 10, W = 2, H […]

Continue Reading