PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Solve frequency sort and all-pairs sum

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in frequency analysis and sorting with tie-breaking by character code, two-pointer pair-sum techniques, deduplication strategies, and algorithmic time and space complexity analysis within the Coding & Algorithms domain.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Solve frequency sort and all-pairs sum

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Task 1 — Frequency-based string reorder: Given a string s containing ASCII characters, return a new string whose characters are ordered by decreasing frequency; when two characters share the same frequency, order them by ascending character code. Describe your chosen data structures and provide time and space complexity. Task 2 — All unique two-sum pairs in sorted array: Given a nondecreasing sorted integer array nums and an integer target, return all unique index pairs (i, j) with i < j such that nums[i] + nums[j] == target. Avoid duplicate pairs when values repeat. Achieve O(n) time and O( 1) extra space (excluding the output) using a two-pointer method. Explain your deduplication strategy and analyze complexity.

Quick Answer: This question evaluates proficiency in frequency analysis and sorting with tie-breaking by character code, two-pointer pair-sum techniques, deduplication strategies, and algorithmic time and space complexity analysis within the Coding & Algorithms domain.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
  • Find the Most Common Visit Pattern - Amazon (hard)
  • Maximize Value Under a Budget - Amazon (medium)
Amazon logo
Amazon
Jul 27, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0

Task 1 — Frequency-based string reorder: Given a string s containing ASCII characters, return a new string whose characters are ordered by decreasing frequency; when two characters share the same frequency, order them by ascending character code. Describe your chosen data structures and provide time and space complexity. Task 2 — All unique two-sum pairs in sorted array: Given a nondecreasing sorted integer array nums and an integer target, return all unique index pairs (i, j) with i < j such that nums[i] + nums[j] == target. Avoid duplicate pairs when values repeat. Achieve O(n) time and O(

  1. extra space (excluding the output) using a two-pointer method. Explain your deduplication strategy and analyze complexity.

Submit Your Answer

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 8,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.