Rubrik SDE-2 System Coding Interview Experience and Concurrency Question
Interview Experience
Hi all, I interviewd for Rubrik recently for SDE-2 role. My first round was System coding in this post will share the question and the solve which i gave. Interviewer was not supportive even my soluti
Full Details
Hi all, I interviewd for Rubrik recently for SDE-2 role. My first round was System coding in this post will share the question and the solve which i gave. Interviewer was not supportive even my solution was correct (accroding to AI tools from which i cross-checked) feeback was Rejected which i think was not fair evaluation. Interviwer seemed arrogant and i think needed only his solution. Three kinds of threads share access to a singly-linked list: searchers, inserters and deleters. - Searchers merely examine the list; hence they can execute concurrently with each other. - Inserters add new items to the end of the list; insertions must be mutually ex-clusive to preclude two inserters from inserting new items at about the same time. However, one insert can proceed in parallel with any number of searches. - Finally, deleters remove items from any-where in the list. At most one deleter process can access the list at a time, and deletion must also be mutually exclusive with searches and insertions. public class Test1 { public Semaphore deleteSemaphore = new Semaphore(2); public Semaphore insertSemaphore = new Semaphore(1); public Integer readCount = 0; public ReentrantLock lock = new ReentrantLock(); public void search(){ lock.lock(); if(readCount == 0){ deleteSemaphore.acquire(1); } readCount ++; lock.unlock(); // read happening lock.lock(); readCount --; if(readCount == 0 ){ deleteSemaphore.release(1); } lock.unlock(); } public void insert(){ deleteSemaphore.acquire(1); insertSemaphore.acquire(1); //insert happening deleteSemaphore.release(1); insertSemaphore.release(1); } public void delete(){ deleteSemaphore.acquire(2); //delete happening deleteSemaphore.release(2); } } Like the post if it helped you. Will share my resources to prepare for system coding round which i referred in another seperate post, after 50 likes on this.