Ruby (Coding)

 60 Minutes
 4 Questions


This coding test is designed to assess a candidate's knowledge of Ruby, data structures, and data manipulation. The test will include questions related to the fundamentals of Ruby, such as syntax, classes, and methods. Additionally, the test will include questions related to data structures, such as arrays, hashes, and linked lists, as well as questions related to data manipulation, such as sorting, searching, and filtering. The test will also include questions related to the use of Ruby to manipulate data structures.


Example Question:

Coding
Bobby has to do n chores today. i-th chore takes a[i] unit of time to complete. It is guaranteed that for every i, the condition a[i] >= a[i]-1 is met, so the sequence is sorted.



Also, Bobby can work hard on some chores. He can choose no more than k chores and do each in x units of time instead of a[i].



Bobby is very responsible, so he has to do all n chores, and now he wants to know the minimum time he needs to do everything. Bobby cannot do two chores simultaneously.



For example, given that:
k = 2, x = 2 and a = [4, 6, 7, 10]



The function should return 14
Since two chores, 7 and 10, can be done in 2 units of time, thus 2+2+4+6 = 14