0% found this document useful (0 votes)
12 views8 pages

Accenture Coding Set C

These are useful preparing Accenture coding round

Uploaded by

Kavya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views8 pages

Accenture Coding Set C

These are useful preparing Accenture coding round

Uploaded by

Kavya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Accenture

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.

Sample Sample Output:


Input:
7 20
10 100 300 200 1000 20 30
3
Question 2
Given two positive numbers N and M, the task is to count the number of digits that are
present in both N and M.

Sample Sample Output:


Input:
N = 748294 4
M = 34298156
Explanation:
The digits that are present in both the numbers are {4, 8, 2, 9}. Therefore, the required
count is 4.
Question 3
Given a positive integer N, count all possible distinct binary strings of
length N such that there are no consecutive 1’s.

Sample Input: Sample Output:


N=2 3

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

Distance is calculated as : sqrt(x2-x1)2 + (y2-y1)2


Question 5
An Autobiographical Number is a number N such that the first digit of N represents the count of how
many zeroes are there in N, the second digit represents the count of how many ones are there in N and
so on.

You are given a function, def FindAutoCount(n):

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:

The input string will not be longer than 10 characters.


Input string will consist of numeric characters.
Note:

If string is None return 0.


Question 5
Sample Input: Sample Output:

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

You might also like