Math, asked by rvedhapriya3466, 10 months ago

Given an array of integers, find out the maximum difference between any two elements such that larger element appears after the smaller number

Answers

Answered by Anonymous
23

 \large\boxed{\underline{\mathcal{\red{A}\green{n}\pink{s}\orange{w}\blue{e}\red{r:}}}}

Given an array arr[ ] of integers, find out the maximum difference between any two elements such that larger element appears after the smaller number.

Examples :

Input : arr = {2, 3, 10, 6, 4, 8, 1}

Output : 8

Explanation : The maximum difference is between 10 and 2.

Input : arr = {7, 9, 5, 6, 3, 2}

Output : 2

Explanation : The maximum difference is between 9 and 7.

Answered by Anonymous
1

Answer:

Given an array arr[ ] of integers, find out the maximum difference between any two elements such that larger element appears after the smaller number.

Examples :

Input : arr = {2, 3, 10, 6, 4, 8, 1}

Output : 8

Explanation : The maximum difference is between 10 and 2.

Input : arr = {7, 9, 5, 6, 3, 2}

Output : 2

Explanation : The maximum difference is between 9 and 7.

Similar questions