×

# What's wrong in my solution

 0 problem link:-https://www.codechef.com/problems/SALARY My solution:-https://www.codechef.com/viewsolution/18786597 asked 05 Jun '18, 19:47 3★bk54 9●3 accept rate: 0%

 1 you are taking the min wrong first you are making mn=ar[0] then checking consider the array 3 2 5 6 your code will return min as 3 but actual min is 2 and also the way you are calculating the ans is wrong as max can change when you increment the other salaries as salaries can be equal so you need to sort the array and add max-min (max=ar[n-1],min=ar[0]) to all the elements from 0 to n-2 as ar[n-1] would be the max add max-min to ans while max!= min then print ans answered 05 Jun '18, 22:05 4★ssp547 307●7 accept rate: 25%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×3,707
×1,901
×1,056
×646

question asked: 05 Jun '18, 19:47

question was seen: 117 times

last updated: 05 Jun '18, 22:05