A challenge from a foreign company or how I failed an interview

Having decided to try my hand at a foreign market, I started sending resumes to various offices. Not even for the purpose of finding a job, but simply for expanding the horizons. The choice fell on the job "Java Developer". I have no industrial experience with the language, only personal experience, certificates from the Oracle Certification Center, books, etc. Honestly, at the last job in a year and a half, I didn’t write anything except the “odds” and “ifs” (but this is a completely different story), so I decided, why not.

Skipping the history of the search and conversations with employers, go to the bottom line. One company K from city G wrote that they were interested in having an interview with me after I solved the problem.

After I decided and sent them the decision, K replied that after the review code they decided not to consider my application more. It was a blow to my self-esteem. Of course, I understand that the language is new, and in general anything happens, but I was hoping for at least a review of my decision. Plus, the task is really simple ... I hope you will be interested in the task.

Below is the original text of the problem.



RESTAURANT EXERCISE (please use JAVA 7 syntax) You

can fit 2, 3, 4, 5 or 6 persons for each table. Clients arrive alone or in groups, up to 6 persons. It is therefore a group that can accommodate them all. If there is a table in the queue.

Once seated, you can’t make it.

In the case of a group of children, it’s not a problem. For example, if there is a table for two, there is a table for two people.

There are no chairs for people to use. , even if the table is bigger than the size of the group.

It’s not worth it.

Please complete the RestManager class with the data methods and implement the three methods. You will be able to modify them.

   publicfinalint size; // number of chairs
   publicfinalint size; // number of clients
   publicRestManager(List<Table> tables){
      // TODO
   // new client(s) show uppublicvoidonArrive(ClientsGroup group){
      // TODO
   // client(s) leave, either served or simply abandoning the queuepublicvoidonLeave(ClientsGroup group){
      // TODO
   // return table where a given client group is seated, // or null if it is still queuing or has already leftpublic Table lookup(ClientsGroup group){
      // TODO

Task analysis

After analyzing the task, it seemed to me and it seems now, well, there is nothing absolutely complicated. However, I immediately want to draw attention to two points that confused me a little.

  1. "If you’re looking for a group of children, it’s not worth it."
  2. RestManager class structure

Regarding the first paragraph, the fact is that our distribution system works according to the above rules, so the situation described in paragraph 1 cannot be avoided. The only thing that I wrote in the reply letter, you can add a delay before issuing a free table. Let's say a group of 3 people comes to a restaurant. At the moment there is a single table on the 6th. By condition, we are obliged to provide them with a table (you must always have a seat at your empty table ... even if there is a table). But if this is not done immediately, but after 5 minutes. During this time there is a chance, albeit a small one, that a place or table with less dimension will be free. But it looks frivolous of course.
On the second point, at least IMHO, the public Table lookup method is not in its class. We can get the table as a getter from a client who, according to ideas, should keep a link to the table.

In general, I highlighted two main points:

  1. It is necessary to sort the tables in the correct order. The logic of finding the right table is simply transferred to sorting. The first table that can accommodate a group of customers and will be necessary.
  2. Only two events necessitate a table search for a client or a client for a table. This is the arrival of a new customer and after the group left the table accordingly.

Actually, the whole task is reduced to the two points above. By the way, the queue collection is useless. The queue is a queue, but by condition any of the queues can be serviced, depending on the available seats and the size of the group, and as a result, we will not use the methods related to the queue.

I leave the link to git with the solution: RestaurantTask

Also popular now: