Category: square-rectangle

Form a Rectangle from boundary elements of Matrix using Linked List

class Node:          def __init__(self, val): = val = None        self.prev = None = 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 != self.head:                                                                                      if j < m and i == 0:       = Node(grid[i][j])                temp =                j += 1                                      elif j == m and i < n - 1:                i […]

Continue Reading

Maximum area of a Cake after Horizontal and Vertical cuts

Given 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 Reading