flipkart logo
Flipkart· SDE-1

Flipkart SDE-1

Posted
2 Oct 2025
388 reads

Summary

I encountered a challenging problem during my Flipkart SDE-1 interview that involved maximizing the number of filled baskets given N balls of various colors and a requirement of K different colors per basket.

How it went

During my Flipkart SDE-1 interview, I was presented with a complex algorithmic problem. The core task was to determine the maximum number of baskets that could be filled. A basket was considered filled if it contained at least K balls of different colors, and I had N balls, with their colors provided in an array. I recognized this as a problem suitable for a binary search approach on the answer. My strategy involved setting left = 0 and right = N / K and then checking if a mid number of baskets was achievable. The check involved iterating through the frequency map of colors; for each color, I could use at most mid balls across all mid baskets. If the total balls used (balls += min(mid, it.second)) met the condition (balls >= (k * mid)), I knew mid was possible and tried for more; otherwise, I reduced my search space.

Questions asked (1)

  1. 01

    Maximize Filled Baskets with K Different Colors

    Data Structures & Algorithms · Hard

    You are given N balls and an integer K. The color of each ball is given in an array. A basket is filled if it contains at least K balls of different colors. Find the maximum number of filled baskets you can get if you optimally put the balls in the baskets.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Flipkart recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!