Hash Ports

Problem Overview

  • Determine the final port for each arriving packet using a hash and port availability.
  • Inputs: numberOfPorts, transmissionTime, packetIds; Output: list of final port numbers.
  • Rules: initial port = packet_id mod numberOfPorts; if busy, try next port; each port takes transmissionTime; packets arrive 1/sec starting at t=1.
  • Domain: networking/packet routing simulation.
  • This coding interview problem is from IBM interviews and is a common interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: