Submitted by: Mohammad Sajid Anwar
You are given an array of numbers with even length.
Write a script to return the count of distinct average. The average is calculate by removing the minimum and the maximum, then average of the two.
Input: @nums = (1, 2, 4, 3, 5, 6)
Output: 1
Step 1: Min = 1, Max = 6, Avg = 3.5
Step 2: Min = 2, Max = 5, Avg = 3.5
Step 3: Min = 3, Max = 4, Avg = 3.5
The count of distinct average is 1.
Input: @nums = (0, 2, 4, 8, 3, 5)
Output: 2
Step 1: Min = 0, Max = 8, Avg = 4
Step 2: Min = 2, Max = 5, Avg = 3.5
Step 3: Min = 3, Max = 4, Avg = 3.5
The count of distinct average is 2.
Input: @nums = (7, 3, 1, 0, 5, 9)
Output: 2
Step 1: Min = 0, Max = 9, Avg = 4.5
Step 2: Min = 1, Max = 7, Avg = 4
Step 3: Min = 3, Max = 5, Avg = 4
The count of distinct average is 2.
Submitted by: Mohammad Sajid Anwar
You are given two strings containing zero or more #.
Write a script to return true if the two given strings are same by treating # as backspace.
Input: $str1 = "ab#c"
$str2 = "ad#c"
Output: true
For first string, we remove "b" as it is followed by "#".
For second string, we remove "d" as it is followed by "#".
In the end both strings became the same.
Input: $str1 = "ab##"
$str2 = "a#b#"
Output: true
Input: $str1 = "a#b"
$str2 = "c"
Output: false
Last date to submit the solution 23:59 (UK Time) Sunday 18th May 2025.