I recently had an onsite which I failed but I was asked 3 design questions including phone screen which I tried to answer to my best of knowledge but I obviously didn’t. I want to learn about these for future interviews, anyone with good suggestions, experience and pointers can help to get me better for next time around - 1. Design a feature for nested comments 2. Design a privacy filter which will have custom visibility 3. Design a system to show mutual friends. TC: 390K SDE3 P.S - Don’t ask me the exact name of the company as I will break the NDA.
1. For one you can have a good document db schema to solve it. A comment will have list of commentIds (as replies), postId, messageHtml, datecreated, lastupdated, commentId etc. i can answer more if u detail the question further 2. Privacy based access. I am assuming this is an rbac component. You need to drill down on a authorization service that figures out roles for a user on the basis of userid or token. Think more on how roles are defined, assigned, and how roles are evaluated for a user. 3.for mutual friends. Each user will have a list of friends as lost of userids. Now between 2 users u need to find mutual friends. Thats basically finding common userids across 2 lists. Set intersection problem. Also scale will matter. In fb there are only 5000 friend limit so it works easily. Now in case this is at a larger scale, which i am not sure. U can solve it using a graph based db too.
“1. For one you can have a good document db schema to solve it” What if it goes 3 or more layers deep and has hundreds or thousands of comments like a reddit thread? I think you didn’t mean that the child comments would be nested within a parent comment’s document — however, that’d also beg the question of why you’d explicitly need a “document DB” when schema flexibility isn’t quite the issue… and then I could be wrong here, but it looked like you might have still been left open to the “N+1 problem” whereas a more effective schema might allow for retrieval of the full tree of comments off a single key-range query instead —- “U can solve it using a graph based db too” 100% wrong. Graph databases can’t scale well and are typically reserved for OLAP use cases. Notice how Facebook’s TAO is an old school SQL DB and not Neo4j? Yeah. Because Neo4j can’t handle scale. —- “Thats basically finding common userids across 2 lists. Set intersection problem. Also scale will matter” That’s a very expensive operation, and it tends to be very read-heavy — So, it’s better to “precompute”. You do that by fanning out new connections to “overlap nodes” between you and each of your friends every time you add a new friend. This is more cost effective as long as the average ratio of new friends to mutual friend lookups exceeds the average number of friends. (For example, I have maybe 500 friends on average on a platform, but every time I check my friends list it shows my mutual friends with them, meaning 20 reads per page view of my friend list. +1 hit on every profile view, and there should obviously be at least one of those for every single connection added because you won’t add a friend without viewing the profile at least once.)
those look like the kind of questions Uber would ask might take a shot at them over the next few weeks over here: youtube.com/@SDFC the privacy filter is for what? details of a user’s account (e.g. LinkedIn, Facebook)? OAuth access permissions (e.g. GitHub’s API)? That 3rd one is a “social graph” — you actually do NOT want to use a graph DB for that. I have coverage here: https://www.youtube.com/live/Jdj2OsGeiA8?si=eWY-MOOlXwslkDYM There’s also coverage for that in Stanley Chiang’s book
thanks a lot for the links, 2nd question is privacy filter for user posts like you see in FB(public/private/friends only etc.)
very interesting! thanks :)
Hey @OP, I recently completed onsite for salesforce. Can I pls dm? I have a few questions:)
sure
Google em
are you asking me to google that term or are you referring to an interview in Google for an EM position? I’m an SDE and I dint appear for an EM interview but nice try!
Tech Industry
Yesterday
2889
The job market is absolutely brutal right now
Tech Industry
Yesterday
2355
Crossed a line with my boss
Tech Industry
Yesterday
1536
I am starting to think Chinese interviewers currently fail non-Chinese candidates on purpose.
Tech Industry
Yesterday
1697
Cute girl on the floor
Tech Industry
Yesterday
925
Update: Trans Coworker Stealing Breast Milk
Thank you for sharing. I haven't heard of these questions earlier and no wondering how to prepare for those.