100% found this document useful (1 vote)
270 views

Accenture Coding Questions

Uploaded by

pradeeba2606
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
270 views

Accenture Coding Questions

Uploaded by

pradeeba2606
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ACCENTURE CODING QUESTIONS

1) Problem Description :
The function accepts two positive integers ‘r’ and ‘unit’ and a positive integer array ‘arr’ of size
‘n’ as its argument ‘r’ represents the number of rats present in an area, ‘unit’ is the amount of
food each rat consumes and each ith element of array ‘arr’ represents the amount of food present
in ‘i+1’ house number, where 0 <= i

Note:

 Return -1 if the array is null


 Return 0 if the total amount of food from all houses is not sufficient for all the rats.
 Computed values lie within the integer range.

Example:

Input:

 r: 7
 unit: 2
 n: 8
 arr: 2 8 3 5 7 4 1 2

Output:

Explanation:
Total amount of food required for all rats = r * unit

= 7 * 2 = 14.

The amount of food in 1st houses = 2+8+3+5 = 18. Since, amount of food in 1st 4 houses is
sufficient for all the rats. Thus, output is 4.
In connection to the National Mathematics Day celebration, the Regional
Mathematical Scholars Society had arranged for a Mathematics Challenge Event
where school kids participated in large number. Many interesting math games were
conducted, one such game that attracted most kids was the tile game where the
kids were given 'n' square tiles of the same size and were asked to form the largest
possible square using those tiles.

Help the kids by writing a program to find the area of the largest possible square
that can be formed, given the side of a square tile (in cms) and the number of
square tiles available.

Input Format

First line of the input is an integer that corresponds to the side of a square tile (in
cms).

Second line of the input is an integer that corresponds to the number of square
tiles available.

Constraints

No Constraints

Output Format

Output should display the area of the largest possible square that can be formed
(in square cms) with the available tiles

Sample Input 0
10
20

Sample Output 0
1600

Sample Input 1
3
15

Sample Output 1
81

You might also like