Implement ASCII canvas and solve two data problems
Company: Asana
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Solve the following coding tasks.
1) **ASCII Canvas / Printer**
Implement a small drawing engine for a fixed-size canvas of **width = 10** and **height = 6**.
- Each cell stores:
- an ASCII character (e.g., 'A', '#', or space)
- an optional color (you can model it as an enum/string; exact coloring output is not important unless you choose to render it)
- Implement these operations:
- `draw_rectangle(char ch, int leftX, int topY, int rightX, int bottomY)`
- Draw a filled rectangle within inclusive coordinates.
- `drag_and_drop(int selectX, int selectY, int toX, int toY)`
- Move the selected cell’s content to the destination.
- **Do not change layer order** (assume there are no layers; treat it as moving that single cell’s content).
- Define what happens to the source and destination cells.
- `erase_area(int fromX, int toX, int fromY, int toY)`
- Clear all cells in the area.
- Provide a way to render/print the canvas as ASCII.
- Discuss edge cases (out-of-bounds coordinates, overlapping operations, empty selections).
2) **Array product excluding self**
Given an integer array `nums`, return an array `out` where `out[i]` equals the product of all `nums[j]` for `j != i`.
- Do **not** use division.
- Target `O(n)` time.
- Extra space should be `O(1)` beyond the output array.
- Handle zeros correctly.
3) **Count IP occurrences in large log files**
You have a very large local log file where each line contains an IP address (possibly with other text).
- Compute how many times each IP occurs.
- Consider that the file may not fit in memory.
- Discuss parsing/validation edge cases and performance tradeoffs.
Quick Answer: This multi-part question evaluates implementation and algorithmic competencies such as managing a mutable ASCII canvas and rendering, in-place array algorithms for the product-excluding-self problem under O(n) time and O(1) extra space, and external-memory parsing and frequency counting for very large log files, including correctness and edge-case handling. It is commonly asked because it tests practical coding ability, correctness under resource constraints, parsing/IO trade-offs and complexity reasoning; the category is Coding & Algorithms with file/systems aspects, and the level of abstraction spans practical implementation and conceptual algorithmic understanding.