You are given three small programming tasks (typical “easy” difficulty). Implement each as a function.
Task 1: Validate parentheses
Given a string s consisting only of the characters '(' , ')' , '{' , '}' , '[' , ']', determine whether it is valid.
A string is valid if:
-
Open brackets are closed by the same type of brackets.
-
Open brackets are closed in the correct order.
-
Every close bracket has a corresponding open bracket.
Input: s (length 0…1e5)
Output: true if valid, else false
Task 2: Longest substring without repeating characters
Given a string s (ASCII), return the length of the longest substring that contains no repeated characters.
Input: s (length 0…2e5)
Output: integer length
Task 3: Fetch from a public GET API and transform
You are given a public HTTP GET endpoint that returns JSON.
Assume the endpoint returns an array of records in the form:
[
{"id":"a1","group":"books","amount":12,"ts":"2026-01-01T10:00:00Z"},
{"id":"a2","group":"books","amount":7,"ts":"2026-01-01T11:00:00Z"},
{"id":"b1","group":"games","amount":20,"ts":"2026-01-02T09:00:00Z"}
]
Write code that:
-
Calls the endpoint.
-
Parses the JSON.
-
Produces a summary per
group
with:
-
count
of records
-
totalAmount
(sum of
amount
)
-
Returns the summary list sorted by
group
ascending.
Constraints/notes:
-
Records may be empty.
-
amount
is a non-negative integer.
-
You may assume the response fits in memory (≤
1e5
records).
-
Focus on correctness and clean error handling (HTTP errors, invalid JSON).