Java Newsletter

Java Newsletter

Share this post

Java Newsletter
Java Newsletter
Java Coding Interview: Zip and Pad Lists

Java Coding Interview: Zip and Pad Lists

Solving Java interview coding question

Suraj Mishra's avatar
Suraj Mishra
Feb 20, 2025
∙ Paid
2

Share this post

Java Newsletter
Java Newsletter
Java Coding Interview: Zip and Pad Lists
1
Share

Question: Zip and Pad Lists

Write a function named zipAndPad() that takes two lists of potentially different lengths as input. The function should return a list of pairs (as lists), where each pair consists of one element from each input list. If one list is longer than the other, pad the missing elements with an empty string.

Examples:

cust_id = { 1, 2, 3 };
cust_name = { "sam", "den", "lenny" };
customers = { {1,"sam"}, {2,"den"}, {3, "lenny"} };

Keep reading with a 7-day free trial

Subscribe to Java Newsletter to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Suraj Mishra
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share