Spark Coding Test for Spark Developers

Here two programs for spark developers :

Question 1:

Mr. Bolt is in his 60’s and loves traveling. He recently visited a country famous for its pens. He has  ‘A’ grandchildren. He went to open Pen shop to purchase pens for them. The shop keeper showed him ‘a’ varieties of pens each variety containing ‘b[i ]’ pens.

He has to select city ‘c’ varieties of pens in a set in such a way that all the ‘A’  grandchildren get the same number of pens. If there are more than one such sets, the one with the minimum number of pens per child should be returned.


input 1: Value of ‘X’

input 2: Value of ‘c’

input 3: Value of ‘a’

input 4: Values in the array ‘b’


Return the minimum number of pens each grand children should get. Return -1 if no solution possible



input 1 : 5

input 2 : 3

input 3: 5

input 4 : {1,2,3,4,5}


Output: 2

Explanation : He can purchase pens in two sets {2,3,45} and {1,4,5}. The sum of each set is 10. Therefore, he will be able to give 2 pens to each of his grand children.


Question 2:

You just got a new job but your new office has different rule. They allow to take interval breaks in between tasks if there is no task available but the problem is that the tasks com randomly and sometimes it may be required  to do them simultaneously.

On your first day, you are given a list of tasks with their starting and ending time. Find out the total time you will get the breaks . Assurance ending time to be greater than  starting time.


Input 1 :  No.of tasks

Input 2 : 2-d array in for [10,11] representing starting and ending time period of the task


Your function must return an integer representing the total break time


input 1: 4

input 2: { (6,8)(1,9)(2,4)(4,7)}

Output: 0

Above Programs are related to Spark using SCALA, Java, Python and R languages for Spark developers.

Leave a Reply

Your email address will not be published. Required fields are marked *