This pair of problems evaluates mastery of fundamental data structures and algorithmic techniques: Problem A tests understanding of stack-based parsing and bracket-matching invariants for validating nested delimiters, while Problem B assesses proficiency with selection algorithms and heap-based priority queues for finding the k-th largest element.
Given a string s containing only the characters '(', ')', '[', ']', '{', '}', determine whether the input string is valid.
A string is valid if:
Input: s (string)
Output: true if s is valid, otherwise false.
Example
s = "()[]{}"
→
true
s = "([)]"
→
false
Constraints (typical): 1 <= |s| <= 10^4
Given an integer array nums and an integer k, return the k-th largest element in the array.
Notes:
k-1
if the array were sorted in descending order.
Input: nums (array of integers), k (integer)
Output: an integer, the k-th largest element.
Example
nums = [3,2,1,5,6,4], k = 2
→
5
Constraints (typical):
1 <= n <= 10^5
1 <= k <= n
nums[i]
fits in 32-bit signed int