Write a function find_outliers(arr) that identifies outlier values in an array using the IQR (Interquartile Range) method.
IQR Method:
1. Sort the data and find Q1 (25th percentile) and Q3 (75th percentile)
2. IQR = Q3 - Q1
3. Lower bound = Q1 - 1.5 * IQR
4. Upper bound = Q3 + 1.5 * IQR
5. Any value outside [lower, upper] is an outlier
Example:
Input: arr = [1, 2, 3, 4, 5, 100, 6, 7, 8, -50]
Output: [100, -50]
Constraints:
Test Cases
Test Case 1
Input:
[1, 2, 3, 4, 5, 100, 6, 7, 8, -50]Expected:
[-50, 100]Test Case 2
Input:
[1, 2, 3, 4, 5]Expected:
[]Test Case 3
Input:
[10, 10, 10, 10, 50]Expected:
[50]+ 2 hidden test cases