Lokesh Ghule's profile picture

Lokesh Ghule

IT 2023
PhonePe
SDE
254 Reads

πŸ† Online Coding Round

Duration: 90 minutes
Total Questions: 4

πŸ“ Problems Given:

  1. Prime Number Cost Problem:

    • Given an array of numbers (Arr) and a cost array (Cost), each number must be formed by summing a single prime number multiple times.
    • The cost of using a prime number x times is x * Cost[i].
    • Example:
      • Arr[i] = 10, Cost[i] = 6
      • 5 + 5 = 10 β†’ Cost = 2 * 6 = 12 (Minimum cost).
  2. Max GCD Sum Problem:

    • Given an array of positive integers, find the maximum sum of GCD(arr[i], arr[i+1]) for all adjacent pairs.
    • You may rearrange the array in any order.
  3. Function Dependency Execution Count:

    • Given an array representing dependencies of functions.
    • Example: { -1, -1, 1, 1, 3 }
      • The 1st & 2nd functions execute anytime (-1).
      • 3rd & 4th execute after the 1st.
      • 5th executes after the 3rd.
    • Find total number of ways to execute all functions.
  4. Max Group Selection:

    • Given two arrays (A and B), select elements forming the largest possible group.
    • Rules:
      • If i-th element is chosen, include at most A[i] elements before i.
      • Include at most B[i] elements after i.
    • Example:
      • A = { 1, 2, 0, 3 }, B = { 2, 2, 0, 1 }
      • Maximum elements in a group = 3.

βœ… Results:

  • Solved 1st problem completely and 2nd problem partially.
  • Got shortlisted for the second round along with 10 other applicants.

⚑ First Technical Interview Round (30–35 min)

πŸ”Ή Questions Asked:

  1. Maximum Subarray Sum of a Circular Array:

    • Array can contain positive & negative elements.
    • Example:
      • Arr = { 2, -4, 3, -5, 1, 3 } β†’ Answer = 6.
    • Progressed from brute force β†’ optimal (O(n)) approach.
    • Dry ran multiple cases β†’ Interviewer was satisfied.
  2. Diameter of a Binary Tree:

    • Initially unaware of this.
    • Interviewer explained the concept.
    • Asked to write pseudo-code for diameter of an N-ary tree.
    • Solved in O(n) time.

βœ… Advanced to the next round along with 5 other applicants.


πŸš€ Second Technical Interview Round (40 min)

πŸ”Ή Questions Asked:

  1. Chocolate Bar Distribution:

    • Given N chocolate bars of varying lengths.
    • Can split bars but NOT attach them.
    • Distribute them to K students such that each gets equal length.
    • Find max possible length per student.
    • Approach: Binary Search on Answer β†’ O(n log n).
  2. Swapped Nodes in a BST:

    • Given a BST where two random nodes were swapped.
    • Find and fix those nodes.
    • Solved in O(n) time.
    • Dry ran multiple cases β†’ Interviewer was satisfied.

🎯 Third HR Interview Round (40 min)

πŸ–₯️ Topics Discussed:

  • Computer Networks:

    • How data packets travel.
    • How HTML, TCP/UDP work.
    • Where & how code gets stored & executed.
    • Interviewer helped wherever I got stuck.
  • OOP & Inheritance:

    • Diamond problem in OOP.
    • Behavior of protected & private members in inheritance.

🧩 Puzzles Asked:

  1. Finding the Faster Mouse:

    • 12 identical mice β†’ 1 is faster.
    • 4 cakes available.
    • Mice can pause/resume eating, can be rearranged anytime.
    • Find the faster mouse.
    • Solved independently.
  2. Fixing Wrongly Labeled Containers:

    • Containers labeled Red, Green, Red+Green but wrongly placed.
    • Balls inside contain only Red, only Green, or both.
    • Find correct labels with minimum ball picks.
    • Solved using 2 balls β†’ Optimized to 1 ball with hint.

βœ… Felt good again after solving these puzzles.


πŸŽ‰ Verdict: Got Selected! πŸŽ‰

  • After 30-minute wait, they felicitated us with goodies.
  • 4 applicants made it to the final selection list.

πŸ”₯ Conclusion

  • A dream come true! πŸ’«
  • Competitive Programming played a major role in my selection. πŸš€

Related Experiences