Just finished a Google onsite yesterday, and the problem was deceptively simple.
No complex DP, no tricky graph theory - just a basic File System simulation.
Many candidates see this type of problem and think: "Easy! This is just DFS, right?" Wrong. If you treat it purely as an algorithm problem, even with bug-free code, you'll likely only get Lean Hire or No Hire.
Let's examine the real details captured during our oavoservice real-time interview assistance.
01 Interview Question (Adapted Version)
Problem Description: Given a file system composed of a series of Entity objects, stored as Map<Integer, Entity>.
Each Entity contains:
id: Unique identifiertype: Type ("File" or "Folder")name: Name- If it's a
File, it has a fixedsize - If it's a
Folder, it contains achildren_idslist
Requirement: Implement function getTotalSize(entityId).
- If it's a file, return its size
- If it's a folder, recursively return the sum of all contained files
Sample data provided by interviewer:
Input Map:
{
100: { type: 'Folder', name: 'root', children: [101, 102] },
101: { type: 'Folder', name: 'downloads', children: [103] },
102: { type: 'File', name: 'logo.png', size: 500 },
103: { type: 'File', name: 'resume.pdf', size: 200 }
}
Call: getTotalSize(100)
Output: 700 (500 + 200)
02 Candidate's First Instinct: Falling into the "Logic Trap"
The candidate started well by clarifying Data Consistency with the interviewer:
"Can we assume all IDs in the Map are valid? Will there be circular references?"
After the interviewer confirmed, the candidate began coding. Like most leetcode-heavy candidates, their brain immediately jumped to templated DFS recursion:
Candidate's subconscious code logic (pseudocode):
// Typical procedural programming mindset
class FileSystem {
Map<Integer, Entity> map;
int getTotalSize(int id) {
Entity e = map.get(id);
if (e.type == "File") {
return e.size;
} else {
int sum = 0;
for (int childId : e.children) {
sum += getTotalSize(childId);
}
return sum;
}
}
}
Does this code work? Yes. Will Google pass you? Unlikely.
Because you're using procedural thinking to write Java/C++. The interviewer frowned slightly, seeing a God Class full of if-else statements instead of an extensible system.
03 oavoservice's Game-Changing Guidance: Replace Conditionals with Polymorphism
During our assistance, we keenly detected the interviewer's expectations. This problem's focus isn't recursion at all - it's Polymorphism.
We quickly prompted the candidate to pause coding and restructure the class design:
Don't judge File vs Folder in FileSystem - delegate the responsibility!
Fileshould know how to calculate its own size (returnsize)Foldershould know how to calculate its own size (iterate throughchildrenand queryFileSystem)
Restructured architecture approach (live implementation):
- Define an interface/abstract class
IEntitywithgetSize()method FileEntityimplements this method: directly returnthis.sizeFolderEntityimplements this method: iterate throughchildrenIdsand call system's get method
After receiving the signal, the candidate immediately understood Google's desired code style:
// Restructured OOD style
interface Entity {
int getSize(FileSystem fs);
}
class FileEntity implements Entity {
int size;
public int getSize(FileSystem fs) {
return this.size; // Clean, pure
}
}
class FolderEntity implements Entity {
List<Integer> children;
public int getSize(FileSystem fs) {
int total = 0;
for (int id : children) {
total += fs.getSize(id); // Delegate back
}
return total;
}
}
04 Outcome: From "Code Monkey" to "Engineer"
After writing this structure, the interviewer's attitude visibly changed. This approach eliminated the ugly if (type == ...) branching logic. The code became extremely clean:
FileSystemlayer only handles lookups, not business logic decisions.
The interviewer then added a Follow-up:
"If we need to add a
SymbolicLinktype, how much of your code needs to change?"
The candidate confidently answered:
"FileSystem class needs zero changes. I just need to add a new
LinkEntityclass implementing the interface."
This is the power of the Open-Closed Principle. And the key to getting Strong Hire in this round.
What if there was no crucial guidance?
If the candidate stuck with the original if-else approach, they would likely crash during the Follow-up. As new types are added, the main function would bloat into a mess, eventually earning the "Lacks System Design Sense" label from the interviewer.
Big tech interviews never test just "getting it right" - they test "design".
🚀 oavoservice Professional Interview Assistance Services
If you're also preparing for Google, Meta, Amazon, TikTok and other big tech algorithm & system design interviews, but struggling with:
❌ Not understanding what interviewers really test
❌ Code works but fails boundary condition challenges
❌ Lack OOD experience, writing "procedural scripts"
Contact oavoservice.
We provide comprehensive job search support services:
✅ Real-time Interview Assistance / External Support (Course-correct thinking at critical moments, avoid pitfalls)
✅ OA Ghostwriting / Test Guarantee (Precise and efficient, 100% pass rate)
✅ Mock Interview Coaching (Replicate real big tech test points, hands-on problem breakdown)
Rather than blindly grinding leetcode alone, find an expert who understands "interviewer psychology" to help you land offers.
📱 Contact Now
WeChat: Coding0201
Get latest North America big tech interview question sets & free resume evaluation. Let oavoservice help you collect offers effortlessly!
Keywords: Google interview, OOP design, polymorphism, interview assistance, interview help, interview cheating, VO assistance, SDE interview, algorithm interview, system design interview, FAANG interview, big tech interview, interview questions