Download and complete the starter notebook
Use the Download starter notebook button on this lesson. Open the .ipynb in JupyterLab, Jupyter Notebook, or another compatible Python 3 environment. Work in a saved copy, complete the TODOs and reflection cells, run the public checks, add the requested tests, then upload that completed .ipynb to this lesson. Do not submit a blank starter. The notebook intentionally contains no answer key or private reviewer rubric.
Instructions
You have 45 minutes for all three problems. Use Python 3 in the downloaded notebook. Keep your implementation and written work in that notebook. Explain your approach before coding, state time and auxiliary-space complexity, and test the listed cases. You may use a different correct algorithm than the examples suggested in the interview prompts.
Problem 1 — Two Sum (Easy, about 10 minutes)
Implement two_sum(nums, target). Return the indices of two distinct elements whose values sum to target. Inputs may have no solution; return [] in that case. If multiple pairs work, any valid pair is accepted. Do not reuse an index.
Examples:
nums = [2, 7, 11, 15], target = 9→[0, 1]nums = [3, 3], target = 6→[0, 1]nums = [], target = 0→[]nums = [1, 2], target = 8→[]
Problem 2 — Longest Substring Without Repeating Characters (Medium, about 15 minutes)
Implement length_of_longest_substring(s) and return the length, in Python string characters, of the longest contiguous substring containing no repeated character. The empty string has answer 0.
Examples: "abcabcbb" → 3; "bbbbb" → 1; "pwwkew" → 3; "" → 0.
Problem 3 — Group Anagrams (Medium, about 15 minutes)
Implement group_anagrams(strs) for strings containing lowercase English letters a–z. Group strings that have the same character counts. Return each input string exactly once. The order of groups and the order within a group do not matter. Empty strings are valid inputs.
Example: ["eat", "tea", "tan", "ate", "nat", "bat"] may produce [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]].
Submit the completed notebook
- Download this lesson's starter Jupyter notebook, complete the requested functions, and upload the saved
.ipynbfile here. - Keep your implementation, added tests, complexity reasoning, and interview reflection in the notebook. No separate source file or
NOTES.mdis required. - Do not upload the untouched starter. Public checks are examples, not a complete test suite; add the edge cases requested in the notebook.
- The downloadable notebook contains no reference solutions or reviewer rubric. Notebook outputs are not used as proof of correctness; the reviewer checks your submitted source and written reasoning.