SAMSUNG R&D Noida | On-site OA | April 2025

samsung logo
samsung
Noida
April 12, 20258 reads

Summary

I encountered a coding problem during my Samsung R&D On-site Online Assessment in April 2025 involving medicine bottle delivery optimization.

Full Experience

Given N medicine bottles and M containers and each container has capacity to carry W[i] bottles. The delivery van can take two containers (only one can also be loaded) to nearby hospital in single trip. Containers can be reused. Find number of trips to deliver minimum N bottles. If not possible, print -1

Contraints 1 <= N,M,W[i] <= 1000 W.length == M

N = 5, M = 2 W[] = {1, 3} Output = 2

N = 6, M = 2 W[] = {4, 5} Output = -1

N = 720, M = 5 W[] = {27, 52, 119, 144, 124} Output = 5

I tried using 2d/3d DP but got TLE.

Interview Questions (1)

Q1
Minimum Trips to Deliver Medicine Bottles
Data Structures & Algorithms

Given N medicine bottles and M containers and each container has capacity to carry W[i] bottles. The delivery van can take two containers (only one can also be loaded) to nearby hospital in single trip. Containers can be reused. Find number of trips to deliver minimum N bottles. If not possible, print -1

Contraints 1 <= N,M,W[i] <= 1000 W.length == M

N = 5, M = 2 W[] = {1, 3} Output = 2

N = 6, M = 2 W[] = {4, 5} Output = -1

N = 720, M = 5 W[] = {27, 52, 119, 144, 124} Output = 5

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

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