Practising this easy grouping and geometry problem
This easy coding problem tests your ability to work with geometric properties and data structure design. Given a collection of lines defined by pairs of points, you need to compute the slope of each line and then group lines by their slope, returning a count of how many lines share each slope value.
The problem rewards clean handling of floating-point arithmetic, thoughtful choice of hash keys or comparison logic, and deliberate edge-case handling. Quant firms value solutions that are correct, readable, and robust—especially when dealing with numerical data where precision matters. Pay attention to how you represent and compare slopes, and remember that the input may be empty or contain only a single line.
- Computing slope from two points
- Grouping and aggregating with hash maps or dictionaries
- Floating-point equality and stability
- Edge-case coverage (empty inputs, degenerate cases)