NPLQLB - Editorial

PROBLEM LINK:

Practice

Contest

Author: Aniket Marlapalle

Tester: Harsh Shah

Editorialist: Aniket Marlapalle

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Implementation

PROBLEM:

Will receive n values one after the other and print the difference of max and min value received until now.

EXPLANATION:

In this problem for all the queries you need to just print the difference of maximum and minimum values that you have received yet.

    for(i=0;i < n;i++){
		sc("%d",&k);
		MAX=max(MAX,k);
		MIN=min(MIN,k);
		k=MAX-MIN;
		pr("%d\n",k);
	}