SRIB Interview Dossier v1 · Java
PRO test cleared · technical round next

You passed the filter.
Now win the room.

The written test was the hard gate — the interview is conversational and very winnable. Real field notes from cleared SRIB candidates point to the same handful of patterns every time. Below is everything, mapped to what actually gets asked, with clean Java you can reproduce on paper.

1 DSA problem, live-coded & explained 15–35 min on your project OS · COA · C++ rapid-fire Approach > answer
§ 00

How Samsung actually interviews

read this first

SRIB technical rounds run 60–90 minutes and are calm by design. The interviewer wants to watch you think, not catch you out. From cleared candidates, the shape is consistent: a warm "tell me about yourself", then a long project deep-dive, then 1 DSA problem you code live and explain, then rapid-fire fundamentals from OS / COA / C++ / DBMS, and a couple of curiosity questions ("do you know about Starlink?").

The one meta-skill they test

Almost every problem follows a ladder: you give brute force → they ask "can you optimize?" → you name the right data structure. Your senior's LCA question was exactly this — an O(n) answer, then "optimize further", then binary lifting. So for every problem below, rehearse the optimization ladder out loud, not just the final code.

The rounds, in order

  1. Tell me about yourself (~3 min). A tight 90-second narrative: who you are, the internship, one flagship project, one line on what you want to build. Rehearse it cold.
  2. Project deep-dive (15–35 min — the biggest chunk). They will ask you to walk the full workflow and sometimes open the codebase. This is where your KnowHow AI / act-vs-ask work is a genuine edge. Own every design decision.
  3. Live DSA (1 problem). Code editor or on paper. They care that your approach is clean and that you can optimize when pushed. Talk while you code.
  4. Fundamentals rapid-fire. OS (semaphores, spinlocks, paging), COA/microprocessor basics, C++ internals (vptr/vtable, singleton), DBMS. Crisp 2–4 line answers win.
  5. Curiosity & fit. A general-tech question and light behavioral. Stay relaxed and genuinely interested.
On-paper coding

Several candidates were asked to write code on paper with no compiler. Practice writing 2–3 of the templates below by hand — clean indentation, correct edge cases, no "// fill later". Muscle memory beats recall under pressure.

Don't over-index on speed

In the written test, any working solution passes — but in the interview the reasoning is graded. Narrate trade-offs, state complexity, and mention the alternative even when you've solved it. "There's also an Euler-tour + sparse-table way" is exactly the kind of line that lands.

§ 01

Tries & bitwise optimization

priority: highest

Two of your senior's problems — sum of prefix scores and maximum subarray XOR — are both tries. The trie shows up in three forms here, and mastering all three is the single highest-ROI thing you can do: a normal character trie, a bit trie (numbers stored MSB→LSB), and Aho-Corasick (in §3). Learn the Java once; reuse it everywhere.

MedMaximum XOR of Two Numbers · LC 421 HardSum of Prefix Scores of Strings · LC 2416 HardMaximum XOR With an Element · LC 1707 HardWord Search II · LC 212

A · Character trie — Sum of Prefix Scores

Every node keeps a cnt of how many words pass through it. Insert all words bumping cnt on each node; then a word's score is just the sum of cnt along its own path. This is the whole trick — no extra structure.

Time O(total chars)Space O(total chars · 26)

B · Bit trie — Maximum XOR (reusable)

Store each number's 32 bits from the most-significant down. To maximise XOR with some value, greedily walk the opposite bit at each level (that sets the bit in the result); fall back to the same bit if the opposite branch is missing. This BitTrie is the workhorse for LC 421, LC 1707, and the subarray-XOR problem.

C · Maximum subarray XOR (the senior's question)

Key identity: xor(l..r) = prefix[r] ^ prefix[l-1]. So maximising a subarray XOR = maximising prefix[i] ^ prefix[j] over pairs. Feed prefix XORs into the same BitTrie — insert the empty prefix (0) first, then for each prefix query the best partner already inside.

If pushed further

LC 1707 adds a constraint (nums[j] ≤ m per query). The move is offline queries: sort both nums and queries ascending, and insert numbers into the trie only up to the current limit as you sweep. Mentioning "I'd sort the queries and build the trie incrementally" signals real CP maturity.

§ 02

Trees & binary lifting

the "optimize the LCA" ask

Your senior gave an O(n)-per-query LCA and was told to optimize — the expected answer is binary lifting: precompute the 2j-th ancestor of every node so each query is O(log n). Same table answers "k-th ancestor" directly (LC 1483). Also drill max path sum — it tests returning state from DFS cleanly.

HardKth Ancestor of a Tree Node · LC 1483 HardBinary Tree Maximum Path Sum · LC 124 HardMin/Max edge weight on a tree path

A · Binary lifting — build once, query in O(log n)

up[j][v] = the 2j-th ancestor of v. The recurrence is the whole idea: a 2j jump = two 2j-1 jumps, so up[j][v] = up[j-1][ up[j-1][v] ]. To find the k-th ancestor, jump along the set bits of k.

B · LCA — what they actually wanted

With depth[] (from one DFS/BFS) plus the same up[][]: first lift the deeper node to equal depth, then lift both together while their ancestors differ. Whatever they land just below is the LCA. This is the O(log n) upgrade the interviewer was fishing for.

Know the alternative

The other clean O(1)-per-query approach is Euler tour + sparse table (RMQ): flatten the tree by an Euler walk and the LCA of u,v is the shallowest node between their first occurrences. Naming both approaches is a strong signal.

C · Binary Tree Maximum Path Sum

One DFS returns the best downward gain from a node (drop negative branches with max(…, 0)). At each node the best path that peaks there is val + left + right — update the global best with it — but you can only extend to the parent through one side.

If they say "no global variable"

Return a small record from each call — e.g. {maxThrough, maxDown} — and combine at the parent. Being ready to refactor away the field is a common follow-up.

§ 03

Advanced string matching

"p codes in a huge string"

"Find the positions of p codes (≤ k bits) in a very large binary string" is textbook multi-pattern matching — the tool is Aho-Corasick (a trie with failure links, one O(n) pass over the text). The streaming cousin is LC 1032 (a reversed trie), and single-pattern search plus the palindrome trick both come from KMP's LPS array.

HardStream of Characters · LC 1032 HardShortest Palindrome · LC 214 MedFind the Index (strStr / KMP) · LC 28

A · KMP — LPS array, then linear scan

lps[i] = length of the longest proper prefix of the pattern that is also a suffix ending at i. On a mismatch you fall back to lps[j-1] instead of restarting — that's what makes search O(n+m).

B · Aho-Corasick — many patterns, one pass

Build a trie of all patterns, then BFS to set failure links (where to jump on a mismatch = longest suffix that is a trie prefix) and turn it into a goto automaton. Scanning the text, follow the suffix-link chain at each position to report every match. For a binary string just set the alphabet to 2. O(Σ|pattern| + |text| + matches).

The streaming variant — LC 1032

If characters arrive one at a time and you must answer "does any word match a current suffix?", insert every word reversed into a trie and walk the stream backwards from the newest char. First end node hit = match. Same trie idea, no failure links needed.

C · Shortest Palindrome — LPS in disguise

To find the longest palindromic prefix of s, build s + "#" + reverse(s) and take the last LPS value. Prepend the leftover suffix, reversed.

§ 04

2D prefix sums & grid queries

subgrid sum in O(1)

"Answer subgrid-sum queries in O(1)" is a 2D prefix table plus inclusion–exclusion. The only thing that trips people up under pressure is the four-term formula and its signs — get that automatic and the harder variants (target-sum counting, maximal rectangle) fall out of it.

MedRange Sum Query 2D Immutable · LC 304 HardSubmatrices That Sum to Target · LC 1074 HardMaximal Rectangle · LC 85

A · The prefix table + inclusion–exclusion

pre[i][j] = sum of the block strictly above-and-left. Any region is then four lookups: total minus the strip above minus the strip left, plus the top-left corner back (it was subtracted twice). Padding by one row/col removes all the edge-case branching.

B · Submatrices summing to target

Fix a top and bottom row, collapse those rows into a 1D column-sum array, and the 2D problem becomes the 1D "count subarrays with sum == k" — solved with a prefix-count hashmap. This 2D→1D compression is a recurring Samsung move.

C · Maximal Rectangle

This one is monotonic-stack, not prefix-sum, but it's the staple matrix problem: for each row build a histogram of consecutive 1s, then run "largest rectangle in a histogram". Reducing a 2D problem to a series of 1D ones is the pattern worth verbalising.

§ 05

Core DSA question bank

tap to expand

The classics from the SRIB question sheet. Each is code-on-paper friendly — tight, correct, and with the one-line insight the interviewer wants to hear you say out loud.

▸Write heap sort and its complexity in different casescode

Insight: build a max-heap in O(n), then repeatedly swap the root (max) to the end and sift down over the shrinking prefix.

Best O(n log n)Average O(n log n)Worst O(n log n)Space O(1)not stable

Unlike quicksort, heap sort has no O(n²) worst case and needs no extra memory — but it isn't adaptive and isn't stable.

▸Implement Kadane's algorithmcode

Insight: at each index, either extend the running subarray or restart at the current element.

Time O(n)Space O(1)

To also return indices, track a start that resets whenever cur restarts.

▸Kahn's algorithm for topological sortcode

Insight: repeatedly remove nodes with in-degree 0. If you can't remove all n, the graph has a cycle.

Time O(V + E)Detects cycles for free
▸Write Dijkstra's algorithmcode

Insight: greedily settle the closest unsettled node using a min-heap; skip stale heap entries. No negative edges allowed.

Time O((V + E) log V)use Bellman-Ford for negative edges
▸Find the k-th smallest element in a BSTcode

Insight: an in-order traversal of a BST visits values in sorted order — stop at the k-th.

Time O(h + k)Space O(h)

If the tree is modified often, augment each node with its subtree size for O(log n) queries.

▸Detect and remove a loop in a linked listcode

Insight (Floyd): slow/fast pointers meet inside the loop. The distance from head to the loop start equals the distance from the meeting point to the loop start — so advance one pointer from head and one from the meeting point until they align.

Time O(n)Space O(1)
▸Design an LRU cachecode

Insight: HashMap for O(1) lookup + a doubly linked list for O(1) recency reordering. Most-recent at the front, evict from the back.

get / put O(1)Shortcut: Java's LinkedHashMap(…, true)
▸k-th largest in an N×M matrix where each row is sortedcode

Insight: keep a min-heap of the k largest seen so far — the heap's top is the answer. Simple and works even without the sorted-row property.

Time O(N·M log k)

If both rows and columns are sorted, upgrade to binary search on the value plus a monotone count: O(N log(max−min)).

▸Implement a circular queuecode

Insight: a fixed array with a head index and a count; wrap with modulo. Tracking count (instead of a tail) avoids the "full vs empty" ambiguity.

All ops O(1)
▸Print the sum of all primes in a given rangecode

Insight: Sieve of Eratosthenes marks composites; a prime's multiples start at p².

Time O(n log log n)
▸Multiply two polynomials (given as coefficient arrays)code

Insight: index = power, value = coefficient. Powers add, coefficients multiply, results accumulate.

Time O(n·m)huge degrees: FFT → O(n log n)

The linked-list version stores (coeff, power) nodes; multiply pairwise into a map keyed by power, then rebuild a sorted list.

▸Find the largest and second-largest — give 4 approachestheory

1 · Sort: sort descending, take the first two distinct — O(n log n). Wasteful but trivial.

2 · Two passes: find the max, then scan again for the max that isn't it — O(n), 2 passes.

3 · Single pass: track first and second; on each element, if it beats first, push first down to second — O(n), 1 pass. This is the answer they want.

4 · Tournament method: pair up and compare like a knockout bracket; the runner-up must have lost only to the champion, so it's among ~log n candidates — n + ⌈log n⌉ − 2 comparisons, the comparison-optimal approach.

▸Which data structure manages files and folders in your mobile?theory

A tree — the directory hierarchy is an N-ary tree (each folder is a node with child files/folders). On disk, the filesystem indexes directory entries with a B-tree / B+ tree (e.g., ext4's HTree, NTFS) because they keep lookups shallow and are disk-block friendly. Path resolution walks the tree like a trie.

▸What is a memory leak and how do you avoid it?theory

Memory that was allocated but never released and is no longer reachable, so it can't be reused — usage grows over time. In C/C++ it's a malloc/new with no matching free/delete.

Avoid: RAII and smart pointers (unique_ptr/shared_ptr), pair every allocation with a deallocation on all paths (including exceptions), and check with Valgrind/ASan. In Java, "leaks" are unintended live references — static collections, un-removed listeners, unclosed resources — that keep the GC from collecting.

▸Difference between dynamic programming and divide & conquertheory

Both split a problem into subproblems. In divide & conquer the subproblems are independent and solved once (merge sort, binary search). In DP the subproblems overlap, so you memoize/tabulate to avoid recomputation (Fibonacci, edit distance). DP additionally requires optimal substructure.

▸Disadvantages of a stack & when recursion overflows ittheory

Disadvantages: only LIFO access (no random access or search), fixed capacity in an array implementation, and no efficient traversal of the middle.

Stack overflow with recursion: every call pushes an activation frame (params, locals, return address). A missing or wrong base case — or legitimately very deep recursion like factorial(1_000_000) — exhausts the call-stack region and throws StackOverflowError. Fix with a correct base case, tail-recursion → iteration, or an explicit stack.

§ 06

Bit manipulation

a SRIB favourite

Samsung Bangalore reliably slips in a bit-twiddling question — cleared candidates report "swap the first 16 and last 16 bits of a 32-bit number" and "how many bits must change to turn A into B". Keep these one-liners loaded.

Say the trick, not just the code

For "swap first/last 16 bits", the line that impresses is: "shift the high half down with an unsigned shift (>>>, so sign bits don't leak in), shift the low half up, then OR them." For counting differing bits: "XOR gives a 1 exactly where they differ, so I just popcount the XOR."

§ 07

Operating systems

semaphores · paging · scheduling

Rapid-fire territory. Your senior noted friends were grilled on semaphores and spinlocks; the SRIB sheet leans on paging, IPC, and scheduling. Two crisp sentences each, plus the producer–consumer you may be asked to write.

▸What is a page fault and why does it occur?

A trap raised when a process accesses a page that isn't currently in physical memory. The MMU can't translate it, so the OS's fault handler fetches the page from disk (or allocates it). It occurs on first touch under demand paging, after the page was swapped out, or on an invalid access (which becomes a segfault).

▸What is virtual memory?

An abstraction giving each process its own large, contiguous address space that can exceed physical RAM, backed by disk. It enables isolation between processes, and lets more processes run than would fit in RAM by paging inactive pages out.

▸What is demand paging?

Loading a page into memory only when it's actually referenced, rather than loading the whole program upfront. It cuts startup time and memory footprint; the cost is a page fault on the first access to each page.

▸Explain semaphores

An integer synchronization primitive with two atomic operations: wait/P (decrement; block if it would go negative) and signal/V (increment; wake a waiter). A counting semaphore guards N identical resources; a binary semaphore (value 0/1) acts like a lock.

▸Semaphore vs mutex vs spinlockasked

Mutex: a lock with ownership — only the locker unlocks; a blocked thread sleeps.

Semaphore: a counter for N resources, no ownership; used for signalling between threads too.

Spinlock: busy-waits in a tight loop instead of sleeping — great for very short critical sections on multicore (no context-switch cost), terrible if held long or on a single core.

▸During a context switch, what's saved and where?

The kernel saves the outgoing process's CPU register context — program counter, stack pointer, general registers — into its PCB (in kernel memory), then loads the next process's context. The process's own stack and heap stay in RAM untouched; only the pointers/registers are swapped, which is why the resumed process finds its frames exactly as it left them.

▸Write the producer–consumer solutioncode

Insight: three semaphores — empty counts free slots, full counts filled slots, and mutex protects the buffer indices.

Order matters: acquire the counting semaphore before the mutex, never the reverse — the opposite order deadlocks.

▸What are swap-in and swap-out?

Swap-out: the OS moves a page/process from RAM to the swap area on disk to free memory. Swap-in: it brings that data back into RAM when needed again. This is how the system runs more than physical memory can hold.

▸Starvation vs aging

Starvation: a process waits indefinitely because higher-priority (or shorter) jobs keep jumping ahead. Aging: the remedy — gradually raise the priority of long-waiting processes so they eventually run.

▸Explain LRU page replacement

On a page fault with memory full, evict the page that has gone unused for the longest time — the assumption being recently used pages will be used again (locality). Exact LRU needs timestamps/a stack; real systems approximate it with reference bits (the clock/second-chance algorithm).

▸IPC types — and which is fastest, and why?

Pipes/FIFOs, message queues, shared memory, sockets, and signals. Shared memory is the fastest: once the region is mapped, processes read/write it directly with no kernel copying per message — the kernel is only involved in setup. The trade-off is you must add your own synchronization (semaphores) since the OS doesn't mediate access.

▸What is fragmentation? Define external fragmentation.

Fragmentation is wasted memory from imperfect allocation. External: enough total free memory exists but it's split into small non-contiguous holes, so a large request can't be satisfied — fixed by compaction or paging. Internal: a fixed block is larger than the request, wasting the remainder inside it.

▸How many processes does N fork() statements create?

2N processes total (i.e. 2N − 1 new children), since each existing process splits into two at every fork(). With three forks: 8 processes, 7 children.

▸What problem does priority scheduling cause?

Starvation of low-priority processes — if high-priority jobs keep arriving, the low-priority ones never get the CPU. The standard fix is aging.

▸What is a real-time OS?

An OS that guarantees tasks complete within strict time bounds (deadlines), where correctness depends on timing. Hard RTOS allows no deadline miss (avionics, pacemakers); soft RTOS tolerates occasional misses with degraded quality (media streaming).

▸Preemptive vs non-preemptive scheduling

Preemptive: the scheduler can forcibly take the CPU from a running process (Round Robin, preemptive priority, SRTF) — better responsiveness. Non-preemptive: a process holds the CPU until it finishes or blocks (FCFS, non-preemptive SJF) — simpler but a long job can hog the CPU.

▸If the time slice exceeds the largest burst, Round Robin behaves like…?

FCFS. No process is ever preempted (each finishes within its quantum), so it degenerates to first-come-first-served.

▸Grant access so only 2 processes can write and 1 can read a file at a time

Use two counting semaphores: a write semaphore initialized to 2 (each writer does P before writing, V after) and a read semaphore initialized to 1 (each reader does P/V around reading). The semaphore value caps the number of concurrent holders at exactly 2 and 1 respectively.

▸Stack pointer vs frame pointer

The stack pointer (SP) always points to the current top of the stack and moves on every push/pop. The frame pointer (FP / base pointer) is fixed for the duration of a function call and anchors access to that frame's parameters and locals at constant offsets — even as SP keeps moving during the call.

§ 08

DBMS

indexing · decomposition · SQL

Compact but frequently asked. Know the indexing family cold and be ready to write the group-wise-max query on paper.

▸What is a view?

A virtual table defined by a stored query — it holds no data of its own; the query runs when the view is accessed. Views simplify complex joins, enforce security (expose only some columns/rows), and provide logical data independence. A materialized view physically stores the result and must be refreshed.

▸What is indexing?

An auxiliary structure (usually a B+ tree, sometimes a hash) that maps a search key to the location of matching rows, turning full-table scans into logarithmic lookups. The cost is extra storage and slower inserts/updates/deletes, since indexes must be maintained.

▸Subject-wise maximum marks — subjects ascending, marks descendingSQL

Insight: group by subject, take MAX(marks), then order.

If they also want which student scored it, use a window function:

▸Primary vs secondary vs clustering vs multilevel indexing

Primary index: built on the ordering key of a sorted file — one entry per block (sparse), fastest and smallest.

Clustering index: on a non-key ordering field, so records with the same value are stored together.

Secondary index: on a non-ordering field; must be dense (an entry per record/bucket) because the file isn't sorted on it.

Multilevel index: an index over the index (the levels of a B+ tree), keeping the top level small enough to sit in memory.

▸Sparse vs dense indexing

Dense: one index entry for every record — supports existence checks without touching the data, but larger. Sparse: one entry per block/group — smaller, but only works when the file is ordered on the key (you land near the record and scan). Sparse trades a little search time for much less space.

▸Lossless vs lossy decomposition

Splitting relation R into R1 and R2 is lossless if their natural join reconstructs exactly R — guaranteed when the common attributes form a superkey of at least one of R1 or R2. It's lossy if the join yields spurious extra tuples (information is effectively lost because you can't tell the originals apart). Good normalization always uses lossless decomposition.

§ 09

C++ & language internals

the biggest rapid-fire pool

The SRIB "general questions for SDE" list is almost entirely this: vptr/vtable, pointers, memory model, and C++ mechanics. Even as a Java-first candidate, have crisp answers here — cleared candidates got singleton, vptr, and templates. Code where it earns its place.

▸Explain VTABLE and VPTRkey

Every class with virtual functions has one shared vtable — an array of pointers to that class's virtual function implementations. Every object of such a class carries a hidden vptr that points to its class's vtable. A virtual call is resolved at runtime: dereference the object's vptr → index into the vtable → jump to the correct override. That indirection is exactly what makes runtime polymorphism work.

▸Implement a thread-safe singletoncode · asked

Best answer (C++11+): the Meyers singleton — a function-local static whose initialization is guaranteed thread-safe by the standard.

Pre-C++11 / if asked to show locking: double-checked locking with an atomic pointer and a mutex — check the pointer, lock only if null, check again inside the lock. Mention that a naive DCL without atomics is broken due to instruction reordering.

▸Function pointer — write one for a function taking int, returning charcode

Read it inside-out: (*fp) is a pointer, (int) its parameters, char its return type. Useful for callbacks and dispatch tables.

▸Implement your own strcat() without <string.h>code

Caller must ensure dest has room for both strings plus the terminator.

▸Big vs little endian — and how to detect itcode

Big-endian stores the most-significant byte at the lowest address; little-endian stores the least-significant byte first (x86, most ARM).

▸Implement 3 stacks in 1 arraycode

Insight: keep a free list of unused cells and a next[] array of links; each stack is a linked chain through the same array, so all space is shared with no fixed partitions.

▸Virtual function & virtual destructor

Virtual function: a member marked virtual so calls dispatch on the object's runtime type via the vtable — the basis of polymorphism.

Virtual destructor: make the base destructor virtual so that delete basePtr; on a derived object runs the derived destructor first. Omitting it → the derived part isn't cleaned up → undefined behaviour / leaks.

▸Abstract class vs pure virtual function

A pure virtual function — virtual void f() = 0; — has no body and must be overridden. A class with at least one pure virtual is an abstract class: it can't be instantiated and serves as an interface. "Abstract function" is just the pure virtual.

▸Early vs late binding

Early (static) binding resolves the call at compile time — normal functions, overloads, non-virtual calls. Late (dynamic) binding resolves at runtime through the vtable — virtual functions. Late binding costs one indirection but enables polymorphism.

▸Deep copy vs shallow copy

Shallow copy duplicates member values including pointers, so both objects share the same underlying buffer — leading to aliasing and double-free. Deep copy also duplicates the pointed-to data, giving fully independent objects. In C++ this is the Rule of Three/Five (define copy ctor, copy assign, destructor — and move versions).

▸void, smart, wild, null, and dangling pointers

void* — typeless pointer; must be cast before dereferencing. Smart pointer — RAII wrapper that owns and auto-frees memory (unique_ptr, shared_ptr, weak_ptr). Wild pointer — uninitialized, points somewhere unknown. Null pointer — points to nothing (nullptr). Dangling pointer — points to memory that has been freed or gone out of scope.

▸Diamond problem

With multiple inheritance, if D inherits from both B and C which each inherit from A, D gets two copies of A's subobject and calls to A's members become ambiguous. Fix with virtual inheritance — class B : virtual public A — so a single shared A subobject exists.

▸Friend class and friend function

A friend is a non-member function or another class granted access to a class's private/protected members. It deliberately relaxes encapsulation for tightly coupled code — e.g. an overloaded operator<< that needs internal access. Friendship isn't inherited or transitive.

▸L-value vs R-value reference

An l-value has an identifiable address (can sit on the left of =); an r-value is a temporary. T& binds l-values; T&& (an r-value reference, C++11) binds temporaries and powers move semantics — stealing resources from a soon-to-die object instead of copying.

▸Principles of OOP

Encapsulation (bundle data + behaviour, hide internals), Abstraction (expose intent, not implementation), Inheritance (derive and reuse), Polymorphism (one interface, many runtime forms). The four pillars.

▸Multilevel inheritance

A chain of inheritance: C derives from B, and B derives from A — grandparent → parent → child, each level extending or overriding the previous. Distinct from multiple inheritance (one class, several direct bases).

▸Inline functions

A request to the compiler to expand the function body at each call site, eliminating call overhead — best for tiny, hot functions. It's only a hint (the compiler may decline), and over-inlining causes code bloat.

▸static vs const variable

They control different things. static affects storage and linkage — a single instance that lives for the whole program (and, at file scope, internal linkage). const affects mutability — the value can't change after initialization. A variable can be both.

▸Where are local / global / static / auto / register / extern / const / volatile stored?

Local/auto → stack. Global & static → data segment (initialized in .data, zero-initialized in .bss). Dynamic (new/malloc) → heap. register → a CPU register if honoured (a hint). extern → just a declaration; the definition lives in the data segment elsewhere. const → often read-only data (.rodata). volatile → wherever it normally lives; the keyword only tells the compiler not to cache/optimize its accesses.

▸Memory layout of a C program

From low to high addresses: text/code (instructions, read-only) → initialized data (.data) → uninitialized data (.bss) → heap (grows upward) → … free gap … → stack (grows downward) → command-line args & environment at the top.

▸Structure padding

The compiler inserts unused bytes so each member starts on its natural alignment boundary and the whole struct's size is a multiple of its largest member's alignment — trading a little space for faster aligned access. Reorder members largest → smallest to shrink padding; #pragma pack forces tighter packing.

▸Name mangling

The compiler encodes a function's name together with its parameter types (and class/namespace) into a unique linker symbol, so overloaded and namespaced names don't collide. extern "C" turns it off so C code can link to the symbol by its plain name.

▸Segmentation fault

A memory-access violation the hardware/OS flags as SIGSEGV — dereferencing a null/wild/dangling pointer, writing to read-only memory, or overflowing the stack. The program is trying to touch memory it isn't allowed to.

▸Do namespaces interact? If so, how?

Yes, but only when you opt in. Via using declarations/directives, argument-dependent lookup (ADL/Koenig — the compiler also searches the namespaces of a call's arguments), and nesting. Namespaces are also open — you can add names to the same namespace across multiple files. They don't silently merge otherwise.

▸sizeof(void) vs sizeof(void*)

sizeof(void) is ill-formed in standard C++ because void is an incomplete type (GCC returns 1 as an extension). sizeof(void*) is the pointer size — 8 bytes on a 64-bit build, 4 on 32-bit.

▸What does malloc(0) return?

Implementation-defined: either NULL, or a unique non-null pointer that you may legally pass to free() but must not dereference. Don't rely on either behaviour.

▸NULL vs NIL

NULL is C/C++'s null-pointer constant (traditionally 0; prefer nullptr in modern C++). NIL is the "no value / empty" notion from other languages (Lisp, Pascal, Objective-C's nil) — not standard C++. Also distinguish both from the null character '\0'.

▸Describe Java's garbage collection

The JVM automatically reclaims objects no longer reachable from GC roots (stack refs, statics). It's generational: most objects die young, so a fast minor GC sweeps the young generation (Eden/survivor) and survivors get promoted to the old generation, collected less often by a major/full GC. Modern collectors (G1, ZGC, Shenandoah) mark → sweep → compact with low pauses.

▸Templates & STLv.v. asked

Templates are compile-time generics — the compiler generates a concrete version per type used (function and class templates). STL is the Standard Template Library built on them: containers (vector, map, unordered_map), iterators, and algorithms. Know the internals: vector doubles its capacity on growth; map is a red-black tree (O(log n), ordered); unordered_map is a hash table (O(1) average).

▸MFC, COM, and DCOM

MFC — Microsoft Foundation Classes, a C++ library wrapping the Win32 API for building Windows GUIs. COM — Component Object Model, a binary interface standard letting components interoperate regardless of language. DCOM — Distributed COM, COM extended so components can communicate across networked machines.

▸Pointer to an array vs typedef vs conio

Pointer to an array of 10 ints: int (*p)[10]; — mind the parentheses; int* p[10] is instead an array of 10 pointers.

Your own typedef: typedef unsigned long ulong; (modern: using ulong = unsigned long;). A complex one names a function-pointer type: typedef char (*Fp)(int);.

conio = Console Input/Output (conio.h) — a non-standard DOS/Turbo-C header.

▸Scheduling — and which data structure is used?

Scheduling decides which ready process gets the CPU next. The ready queue is the structure: a plain FIFO queue for Round Robin, a priority queue / heap for priority scheduling, and a red-black tree in Linux's CFS (keyed by virtual runtime).

▸Exceptions that try/catch can't catch — can we still avoid a crash?

Some failures aren't C++ exceptions: OS faults like a segfault (SIGSEGV) or divide-by-zero, and exceptions thrown during stack unwinding (which call std::terminate). You can intercept OS-level faults with platform mechanisms — SEH (__try/__except) on Windows, signal handlers on POSIX — and install a std::set_terminate handler, so you can log and shut down gracefully, but you generally can't safely resume. In Java the analogue is Error (e.g. StackOverflowError): technically catchable, but not something to rely on.

§ 10

Computer networks

TCP/IP essentials

Light but expected — TCP vs UDP and the TCP/IP stack come up in almost every list.

TCP vs UDP

AspectTCPUDP
ConnectionConnection-oriented (handshake)Connectionless
ReliabilityReliable — acks, retransmission, orderedBest-effort — no guarantee, may reorder/drop
ControlFlow + congestion controlNone
Speed / overheadSlower, heavier header (20 B)Fast, light header (8 B)
UnitByte streamDatagrams
Used byHTTP(S), FTP, SMTP, SSHDNS, DHCP, VoIP, streaming, games
▸Protocols at each layer of the TCP/IP model

Application: HTTP(S), FTP, SMTP, DNS, DHCP. Transport: TCP, UDP. Internet: IP, ICMP, ARP, routing. Network Access / Link: Ethernet, Wi-Fi (802.11), MAC.

▸Explain client-server architecture

A model where clients request services and a central server provides them (data, compute, files). Resources are centralized — easier to manage and secure, but the server is a single point of failure and a scaling bottleneck. Contrast with peer-to-peer, where every node is both client and server.

§ 11

Project deep-dive & behavioral

the biggest scoring chunk

Field notes are unanimous: 15–35 minutes go to your project, sometimes with the interviewer reading your code. This is your home turf — you're interviewing at the exact org whose product (Bixby) your KnowHow AI work targets. Own every decision and you separate yourself from every rote-DSA candidate.

Your unfair advantage

Your act-vs-ask problem — teaching a small on-device model when to act on an ambiguous smart-home command vs ask for clarification — is directly relevant to Bixby. Lead with it. Very few candidates walk in with a project that is the interviewer's roadmap.

1 · "Tell me about yourself" — the 90-second open

Rehearse this cold. A clean shape: who you are (final-year dual-degree CS at BITS Pilani) → what you're doing now (SRIB intern on the KnowHow AI project, improving Bixby's handling of implicit commands) → one flagship result (distilling a black-box teacher into an on-device Gemma student that knows when to act vs ask) → what you want (build applied-ML / agentic systems at scale). Land it in under two minutes and stop.

2 · The project narrative — hit these beats in order

  1. Problem, in one line. Bixby mishandles implicit smart-home commands — goal-stated, routine-implied, deictic. The model must resolve them without over-acting on ambiguity.
  2. Why it's hard. On-device constraints (a small Gemma student), a black-box teacher (Gemini 2.5 Pro — no logits, no gradients), and the safety asymmetry: acting wrongly is worse than asking.
  3. Your pipeline. Knowledge distillation into Gemma 4 E4B, a bi-temporal knowledge graph (FalkorDB + Graphiti) for home context, and calibrated selective prediction — the act-vs-ask decision head.
  4. The key trade-off. Sequence-level SFT + rationale distillation + counterfactual minimal pairs, with GRPO deprioritized because the teacher is a black box — no reward signal to optimize against cleanly.
  5. How you measured it. HomeBench / SimuHome, calibration under ambiguity, and the act-vs-ask decision quality.

3 · Anticipate the deep-dive questions

  • "Why distillation and not just fine-tuning?" — The teacher encodes reasoning the small model can't learn from labels alone; rationale distillation transfers the why, not just the answer.
  • "Why did you drop GRPO / RL?" — A black-box teacher gives no clean reward; SFT + counterfactual pairs was higher signal-per-compute for the on-device target.
  • "Why a knowledge graph and not RAG over text?" — Home state is relational and temporal (devices, routines, who did what when); a bi-temporal graph answers "what's true now vs what was true" that flat retrieval can't.
  • "How do you decide act vs ask?" — Calibrated selective prediction: act only when confidence clears a threshold tuned to the cost asymmetry; otherwise ask. Frame it as precision/recall on the "act" decision.
  • "Walk me through the code." — Have the orchestration (the agent loop over the graph) and the training script clear in your head. Be able to point to one thing you'd refactor.
Curiosity questions (the "Starlink" type)

These aren't gotchas — they check whether you're genuinely curious about tech. The night before, skim a little recent AI/systems news so you can chat about something current with real interest. If you don't know the specific thing, say so and reason about it out loud — that's the actual test.

4 · Behavioral — keep answers STAR and short

  • Why Samsung / SRIB? Tie it to the work — on-device intelligence, Bixby, applied research that ships to real devices. You've already been doing it as an intern.
  • A hard bug / conflict / failure. Use Situation → Task → Action → Result. One concrete story, quantified result, one line on what you learned.
  • Strength / weakness. A real weakness plus the concrete thing you do to manage it — not a humblebrag.
  • Questions for them. Always have two ready — about the team's roadmap or how research transfers to product. It signals you see yourself there.
§ 12

Puzzles

occasional, low-stakes

Some candidates get a logic puzzle. They're low-weight and reasoning is what's graded — think aloud, state assumptions, and don't freeze. Skim a handful the night before.

The categories worth one pass

  • Measuring / pouring: the 3L & 5L jug to get 4L — classic BFS-on-states logic.
  • Weighing: find the odd coin / heavier ball in the fewest weighings (ternary thinking).
  • Egg drop: minimum trials to find the breaking floor — a DP flavour.
  • Probability: Bayes-style ("Monty Hall", two-children), and expected-value questions — relevant since you're on an ML track.
  • Bit / number puzzles: swap without a temp, detect power of two, count bits — overlaps §06.
§ 13

Battle plan

tick as you go

Pick the track that matches your runway. Progress saves in your browser, so you can close this and come back.

Prep progress
0%
If the interview is tomorrow

Do only the highest-yield: the character trie + bit trie + 2D prefix sum templates (most likely to appear), rote the OS/C++ one-liners (semaphore vs spinlock, vptr/vtable, thread-safe singleton), and rehearse your 90-second project open out loud twice. Skip Aho-Corasick's code but be able to name it.

Day 1–2 Core patterns, coded by hand

Day 3 String matching + DSA bank

Day 4 Fundamentals rapid-fire

Day 5 The room

In the room — the three habits

1. Think out loud; give brute force first, then optimize. 2. State complexity and name the alternative approach even when you've solved it. 3. Stay calm and curious — the interviewers are relaxed by design, so match that energy. You already cleared the hard part.