Panda Guru LogoPanda
Guru

Zepto SDE 2 Round 1

Round 1

Questions:

  1. Problem 1: Destination City
    Link: Destination City
    My solution:

    class Solution { public: string destCity(vector<vector<string>>& paths) { unordered_map<string,int> outgoing_edges; for(auto &vec : paths) { outgoing_edges[vec[0]]++; } for(auto &vec : paths) { if(outgoing_edges[vec[1]] == 0) { return vec[1]; } } return ""; } };
  2. Problem 2: Rabbits in Forest
    Link: Rabbits in Forest
    My solution:

    class Solution { public: int numRabbits(vector<int>& answers) { unordered_map<int,int> mp; for(auto x : answers) { mp[x]++; } int cnt,val,extra=0,bucket,cur; for(auto p : mp) { cnt = p.second; val = p.first; bucket = 1 + val; cur = cnt % bucket; extra += (bucket - cur) % bucket; } return answers.size() + extra; } };
Candidate's Approach

The candidate was able to solve both problems and explained their approaches, as well as the time complexity (TC) and space complexity (SC) for each solution.

Interviewer's Feedback

No feedback provided.