Skip to the solution
EasyDSAAsked in 20246 min read

Unzip Array

761 views

The problem

Problem, as an interviewer would state it: "Implement unzip(zipped) — the genuine inverse of zip, taking a single array of grouped tuples and separating it back into multiple, parallel arrays."

Examples:

Code
unzip([[1,"a"], [2,"b"], [3,"c"]]); // [[1,2,3], ["a","b","c"]]

Clarifying questions expected:

  • Is this genuinely the exact inverse of zip — does unzip(zip(a, b)) need to reproduce [a, b] exactly?
  • What if the tuples themselves have varying lengths — should the output account for the LONGEST tuple?
  • What real, correct output should an empty input array produce?

Code / implementation expected: Yes — real, direct proof that this is the genuine inverse of zip, confirmed via a full round trip through both functions.

  • array

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

6 min read · 9 sections

Run the code

Edit the code and run it here. Each console line with an expected value becomes a test.

JavaScriptReal, direct proof: unzip() is the genuine inverse of zip, confirmed via a full round trip reproducing the exact original arrays

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 32 of 154 in JavaScript coding

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

Up nextEasy

Remove elements in-place

Continue