Given a string of galactic coordinates in the format of (latitude, longitude), determine if the coordinates are properly nested, i.e., every open parenthesis has a corresponding close parenthesis and the pairs of coordinates are properly nested.
Explanation: Step-by-step: with input (1, 2) (3, 4), we first check if the first parenthesis is properly nested, which it is. Then, we check if the second parenthesis is properly nested, which it is. Since both parentheses are properly nested, the output is True.
Explanation: Step-by-step: with input (1, 2) (3, 4)), we first check if the first parenthesis is properly nested, which it is. Then, we check if the second parenthesis is properly nested, which it is not because there is no corresponding opening parenthesis. Since the second parenthesis is not properly nested, the output is False.
Master coding challenges related to Stack and solve the [Backup] Galactic Coordinate Parser problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak