Practise a technical internship interview with a worked coding problem
SkillNexis · 2026-08-01 · Updated 2026-10-21
A useful mock interview checks how you reason, not only whether you remember syntax. Use the following original practice task for a 25-minute session with a friend or by recording yourself. It is not a question attributed to a particular employer, and completing it does not predict an interview result.
Minutes 0–4: clarify the task
Given an array of strings, return the first value that appears for a second time while reading from left to right. Return null when no value repeats. Matching is case-sensitive. For ['api', 'ui', 'api', 'db', 'ui'], the answer is 'api'. Ask whether values may be empty strings, whether the input can be modified, and whether the caller needs the repeated value or its index. For this exercise, empty strings are valid and the input must stay unchanged.
Minutes 4–9: explain a baseline
One approach compares each value with everything before it. It is easy to describe but can make a quadratic number of comparisons as the list grows. Explain that tradeoff before introducing a Set of previously seen strings. Scan left to right, check whether the value is already present, and return it immediately if so. Otherwise add it and continue. The order of checking and adding matters: adding first would make every value look like a duplicate.
function firstRepeated(values) {
const seen = new Set();
for (const value of values) {
if (seen.has(value)) return value;
seen.add(value);
}
return null;
}
console.log(firstRepeated(['api', 'ui', 'api', 'db', 'ui']));
console.log(firstRepeated(['API', 'api']));
The first console output is 'api'; the second is null. On typical Set implementations this approach has expected linear running time and uses space proportional to the number of distinct strings. State that assumption rather than claiming the language guarantees constant time for every Set operation.
Minutes 9–15: test the meaning of “first”
- Empty input returns null.
- ['x', 'x'] returns 'x'.
- ['x', 'y', 'y', 'x'] returns 'y', because its second occurrence is encountered first.
- ['API', 'api'] returns null under case-sensitive matching.
- ['', ''] returns the empty string, not null.
Check the original array after calling the function. It should have the same values in the same order. If you sort it to group duplicates, you lose the encounter order and change the question being answered. If a requirement changes to case-insensitive matching, discuss whether the return value should preserve the original spelling before editing the implementation.
Minutes 15–22: connect the reasoning to a project
Prepare a two-minute explanation of one feature you built: the user’s problem, the input, the output, one failure case and a decision you made. For a task tracker, demonstrate that completing one task does not alter another. Open the deployed project and a relevant test. Describe measurements only when you actually collected them. It is fine to say that a project uses sample data or has no real users yet.
Minutes 22–25: write a follow-up plan
Record one unclear assumption, one missed edge case and one explanation to shorten. Repeat the same task the next day before trying a harder one. For further practice, merge overlapping calendar intervals and explain why a nested interval must not shrink the result. Review project evidence on your resume before linking the work in an application.
Reference: MDN’s Set reference describes uniqueness, equality and performance requirements.