Answer two coding questions (SQL and DP)
Company: Amazon
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This multi-part question evaluates SQL query skills (handling distinct values, aggregation and edge-case NULL results) and algorithmic proficiency in dynamic programming on strings, specifically counting distinct palindromic subsequences under modular arithmetic.
Second Highest Distinct Salary
Constraints
- Distinct salaries matter
Examples
Input: ([100, 200, 300],)
Expected Output: 200
Input: ([100, 100],)
Expected Output: None
Input: ([],)
Expected Output: None
Input: ([5, 5, 3, 4],)
Expected Output: 4
Hints
- Sort unique salaries descending.
Count Distinct Palindromic Subsequences
Constraints
- s contains lowercase English letters
Examples
Input: ('bccb',)
Expected Output: 6
Input: ('aaa',)
Expected Output: 3
Input: ('abcd',)
Expected Output: 4
Input: ('aba',)
Expected Output: 4
Hints
- Use interval DP and handle duplicate boundary characters carefully.