Back to feed
Single Experience
LG
Lokesh Ghule's profile picture
Interview Experience
Lokesh Ghule
PhonePe
SDE
IT 2023
Saturday, February 15, 2025
853 reads
3 min read

🏆 Online Coding Round

Duration: 90 minutes
Total Questions: 4

📝 Problems Given:

  1. Prime Number Cost Problem:
    • Given an array of numbers (
      code
      1Arr
      ) and a cost array (
      code
      1Cost
      ), each number must be formed by summing a single prime number multiple times.
    • The cost of using a prime number
      code
      1x
      times is
      code
      1x * Cost[i]
      .
    • Example:
      • code
        1Arr[i] = 10
        ,
        code
        1Cost[i] = 6
      • code
        15 + 5 = 10
        → Cost =
        code
        12 * 6 = 12
        (Minimum cost).
  2. Max GCD Sum Problem:
    • Given an array of positive integers, find the maximum sum of
      code
      1GCD(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:
      code
      1{ -1, -1, 1, 1, 3 }
      • The 1st & 2nd functions execute anytime (
        code
        1-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 (
      code
      1A
      and
      code
      1B
      ), select elements forming the largest possible group.
    • Rules:
      • If
        code
        1i-th
        element is chosen, include at most
        code
        1A[i]
        elements before
        code
        1i
        .
      • Include at most
        code
        1B[i]
        elements after
        code
        1i
        .
    • Example:
      • code
        1A = { 1, 2, 0, 3 }
        ,
        code
        1B = { 2, 2, 0, 1 }
      • Maximum elements in a group =
        code
        13
        .
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:
      • code
        1Arr = { 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
      code
      1N
      chocolate bars of varying lengths.
    • Can split bars but NOT attach them.
    • Distribute them to
      code
      1K
      students such that each gets equal length.
    • Find max possible length per student.
    • Approach: Binary Search on Answer →
      code
      1O(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. 🚀

Reads: 853

Shared on theInterview community feed

Related Experiences

Hand-picked interview stories similar to this one.

8 posts