Accenture Coding Set C
Accenture Coding Set C
Topic/Course
Sub-Topic (Example: name of college)
Programs
Question 1
You are given a function: def MinimumUnfairness(arr, k): The function
accepts an integer array 'arr' of length n' and an integer k. If (x1, x2,
x3,...xk) are k numbers randomly selected from the array 'arr', the
Unfairness is defined as max(x1, x2,..., xk) - min(xl, x2, ..., xk), where max
denotes the largest integer among the k elements, and min denotes the
smallest integer among the k elements. Select k integers from the array
'arr' such that its unfairness is minimized and return minimized unfairness
value.
Explanation:
The 3 strings are 00, 01, 10
Question 4
The program is supposed to calculate the sum of distance between three
points from each other.
For
x1 = 1 y1 = 1
x2 = 2 y2 = 4
x3 = 3 y3 = 6
The function accepts string “n” which is a number and checks whether the number is an
autobiographical number or not. If it is, an integer is returned, i.e. the count of distinct numbers in ‘n’. If
not, it returns 0.
Assumption:
N = 1210 3
Explanation:
0th position in the input contains the number of 0 present in input, i.e. 1, in 1st position the count of number of 1s
in input i.e. 2, in 2nd position the count of 2s in input i.e. 1, and in 3rd position the count of 3s i.e. 0, so the number
is an autobiographical number.
Now unique numbers in the input are 0, 1, 2, so the count of unique numbers is 3. So 3 is returned.
THANK YOU