Determine feasibility and clean parentheses string
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This pair of problems evaluates proficiency with graph algorithms (dependency modeling and cycle detection/topological ordering) and string processing (parentheses balancing and minimal-edit transformations), focusing on algorithmic thinking, data-structure usage, and efficient linear-time solutions.
Can Finish Courses
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: (2, [[1,0]])
Expected Output: True
Explanation: No cycle.
Input: (2, [[1,0],[0,1]])
Expected Output: False
Explanation: Cycle prevents completion.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.
Minimum Remove To Valid Parentheses
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('lee(t(c)o)de)',)
Expected Output: 'lee(t(c)o)de'
Explanation: Already valid string is unchanged.
Input: ('a)b(c)d',)
Expected Output: 'ab(c)d'
Explanation: Remove unmatched close parenthesis.
Input: ('))((',)
Expected Output: ''
Explanation: Remove all invalid parentheses.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.