Posts

Showing posts from November, 2021

Convex Hull

Image
 Adobe Goldman Sachs Morgan Stanley Ola Cabs Samsung Hard  Convex Hull of a set of points, in 2D plane, is a convex polygon with minimum area such that each point lies either on the boundary of polygon or inside it. Now given a set of points the task is to find the convex hull of points.   Example 1: Input: points_list = {{1,2},{3,1},{5,6}} Output: {{1,2},{3,1},{5,6}} Example 2: Input : points_list = {{5,1},{4,4},{1,2}} Output: {{1,2},{4,4},{5,1}}   Your Task: You don't need to read or print anything. Your task is to complete the function  FindConvexHull()  which takes points_list as input parameter and returns Convex Hull of given points in a list. If not possible returns a list containing -1.   Expected Time Complexity:  O(nlog(n)) Expected Space Complexity:  O(n) where n = total no. of points Constraints: 1 <= n <= 10 4 -10 5  <= x, y <= 10 5 Code: // A C++ program to find convex hull of a set of points. Refer // https://www.geeksforgeeks.org/orientation-3-ordered-

The One Where They Get Back Together

Image
  F.R.I.E.N.D.S   stars Jennifer Aniston, Courteney Cox, Lisa Kudrow, Matt LeBlanc, Matthew Perry and David Schwimmer have come together for the much-awaited reunion. The whole cast is going to shoot for the episode on the sets of their show. Being a huge fan, Chef's family is excited to watch the live shoot. The set has infinite rows with infinite seats in each row for the audience. The seats are numbered starting from  1 1  as shown in the image above. Let the seat number of the seat in the  i t h i t h  row and  j t h j t h  column be  S i , j S i , j . The price of a seat is equal to the seat number of that particular seat. Chef wants to reserve exactly  N N  seats for his family members such that the reserved seats form a rectangle and all the family members stay together. Chef is allowed to choose a reduction price  X X . After choosing the value of reduction price; if Chef has chosen the seat in the  i t h i t h  row and  j t h j t h  column, the price of this seat becomes