I haven't return the full runnable code in interview this is generated by chatgpt based on my input
---------
Question
---------
Each page has metadata:
empty bit → whether page is used
offset of next page → pointer (like a linked list)
Example chain:
P1 → P2 → P3 → P10
P2 → P5
Page states:
P1: not empty → next = P3
P2: not empty → next = P5
P3: not empty → next = P10
P4: empty (garbage)
P5: not empty → EOF (sentinel)
P0 = master page
It normally stores starting offsets of all files (i.e., heads of each chain).
But P0 is corrupted, and we must reconstruct the master page.
-------
Code
-------
import java.util.*;
class Page {
int id;
boolean isEmpty;
Integer next; // null means EOF
Page(int id, boolean isEmpty, Integer next) {
this.id = id;
this.isEmpty = isEmpty;
this.next = next;
}
}
public class RecoverMasterPage {
public static List<Integer> recoverMasterPage(List<Page> pages) {
Set<Integer> used = new HashSet<>();
Set<Integer> pointed = new HashSet<>();
// Step 1: collect used pages and next pointers
for (Page p : pages) {
if (!p.isEmpty) {
used.add(p.id);
if (p.next != null) {
pointed.add(p.next);
}
}
}
// Step 2: start pages = used - pointed
used.removeAll(pointed);
// Step 3: return sorted offsets (optional)
List<Integer> masterOffsets = new ArrayList<>(used);
Collections.sort(masterOffsets);
return masterOffsets;
}
// Demo
public static void main(String[] args) {
List<Page> pages = List.of(
new Page(1, false, 3),
new Page(2, false, 5),
new Page(3, false, 10),
new Page(4, true, null), // empty
new Page(5, false, null) // EOF
);
List<Integer> master = recoverMasterPage(pages);
System.out.println("Recovered P0 offsets: " + master);
}
}
Direct candidate, applied through careers page. OA completed and selected for r1(dsa/lld/psa) and r2 (lld/hld). But got rejected in r1 itself. All the best for other out there, Unable to remember the OA questions exactly,
OA - 90 mins, attended 2 OA's different role. After OA got call for one role only in that also rejected in r1. Dont want my knowledge to go vain so sharing here! Hopes this helps! If you feel u didnt get any calls! wait get ready urself because when the interview call comes thats your only chance so dont waste it keep prepare and be ready always! U may receive call at some point so dont waste it! I started the preparation feb 2025 and here i'm in feb 2026 still hoping for the best! so keep running!
One advice dont start if u r going to stop in mid way!
In past one year i didn't receive single call but in past one month i received nearly 4 call from microsoft itself without referral! So keep push urself learn as much as u can!
Yes, I didn’t win this time, but I will!
Hope this motivate atleast one or two out there like me! All the best guys!
verdict - rejected in all 2 roles.