Question: Second time submitted this problem can i PLEASE get the answer in KOTLIN thank you. Create a public class called Last40rdered. You should expose two

Second time submitted this problem can i PLEASE get the answer in KOTLIN thank you.

Second time submitted this problem can i PLEASE get the answer in

Create a public class called Last40rdered. You should expose two public methods: - add: adds a value, does not return a value - last: returns an array containing the last 4 values that were added in the order they were added. You do not need a constructor, but you can add an empty one if you need. Until 4 values have been added you should return 0 s in their place. For example, here's how an instance of Last40rdered should work: 1 val example = Last40rdered () 2 println(example. last()) // prints [,,,] 3 example.add(1) 4 println(example. last())// prints [1,,,] 5 example.add(2) 6 println(example. last())// prints [1,2,0,0] 7 example.add(3) 8 example.add(4) 9 example.add(5) 10 println(example. last())// prints [2,3,4,5] Do not create a huge array to save the values. Submissions that do will be marked incorrect. This problem is harder than it looks! A suggestion is to handle the cases until the array is initially filled separately. Once four values have been added, you will need to shift values around before adding a new one

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!