PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Amazon

Answer two coding questions (SQL and DP)

Last updated: Mar 29, 2026

Quick Overview

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.

  • medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Answer two coding questions (SQL and DP)

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Solve the following two coding tasks. ## Problem A (SQL) You are given a table: **Employee(id INT, salary INT)** Write a query that returns the **second highest distinct salary** in the company. - If there is no second distinct salary, return `NULL`. ## Problem B (Dynamic Programming on strings) Given a string `s` (lowercase English letters), compute the **number of distinct non-empty palindromic subsequences** of `s`. Requirements: - Return the count modulo `1_000_000_007`. - Subsequences are formed by deleting zero or more characters without reordering. - Two subsequences are considered different if their resulting strings differ. Constraints (typical): - `1 <= len(s) <= 1000`

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.

Related Interview Questions

  • Find Unique Target-Sum Pairs - Amazon (easy)
  • Find Valid IP Addresses in Files - Amazon (medium)
  • Implement Optimal Bucket Batching - Amazon (hard)
  • Implement Cache and Rotate Matrix - Amazon (medium)
  • Find Longest Activatable Server Streak - Amazon (hard)
Amazon logo
Amazon
Feb 12, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
19
0
Loading...

Solve the following two coding tasks.

Problem A (SQL)

You are given a table:

Employee(id INT, salary INT)

Write a query that returns the second highest distinct salary in the company.

  • If there is no second distinct salary, return NULL .

Problem B (Dynamic Programming on strings)

Given a string s (lowercase English letters), compute the number of distinct non-empty palindromic subsequences of s.

Requirements:

  • Return the count modulo 1_000_000_007 .
  • Subsequences are formed by deleting zero or more characters without reordering.
  • Two subsequences are considered different if their resulting strings differ.

Constraints (typical):

  • 1 <= len(s) <= 1000

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.