AT003 - Editorial




You are provided with a set of elements in which each element may contain one integer or two integers which represents start line or start and end line of time intervals respectively. If between two or more elements intervals overlap then combine those intervals and give the list of final time intervals along with intervals that are not overlapped with any other.


The program is divided into different functions to make the logic more understandable.

Structure :

struct pair : This is a structure which represents a set of two integers which are notated by first and second variables.


struct pair a[] - This is the declaration of an array whose data type is exactly of that structure on which it is defined.


int comp(const void *a,const void *b) : This function takes two numbers and returns whether the first number that is taken is bigger than the second number or not.As we use structure,in order to access it we again declare objects to that structure locally.

int max(int a,int b):Upon taking two integer values this function return the value of the integer which is larger.

Solution: click here to see the solution