PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Solve jumps and anagram-similarity problems

Last updated: Mar 29, 2026

Quick Overview

This two-part question evaluates algorithmic problem-solving skills: Task A focuses on combinatorial optimization and cost-based sequencing under quadratic jump costs, while Task B assesses string multiset reasoning and character-frequency manipulation to determine anagram similarity.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Solve jumps and anagram-similarity problems

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

You are given two independent tasks. Task A (Maximize calories over jumps): - There are n blocks with integer heights height[i] ≥ 0. - You start on the ground at height 0. You must visit every block exactly once in any order. After the first jump from the ground to some block, you may only jump between blocks; you cannot return to the ground. - The calories consumed for a jump from a location of height x to a location of height y is (x − y)^2 (the ground’s height is 0). - Choose an order of visiting the n blocks that maximizes the total calories across all n jumps (ground → first block plus the n−1 subsequent block-to-block jumps). Return the maximum total as an integer. - Example: n = 3, height = [5, 2, 5] ⇒ 43. - Describe your algorithm and analyze its time and space complexity. Task B (Password similarity under character-removal): - For each test case, you are given two lowercase strings password1 and password2. - You may remove all occurrences of at most one chosen character from password1, and independently remove all occurrences of at most one chosen character from password2. You may also choose to remove nothing from either string. - After these removals, the strings are considered similar if they are anagrams (i.e., they have identical character multisets). - For each test case, return true if the strings can be made similar under this rule, otherwise return false. - Example: password1 = "safddadfs", password2 = "famafmss" ⇒ true (remove all 'd' from password1 and all 'm' from password 2). - Describe your algorithm and analyze its time and space complexity.

Quick Answer: This two-part question evaluates algorithmic problem-solving skills: Task A focuses on combinatorial optimization and cost-based sequencing under quadratic jump costs, while Task B assesses string multiset reasoning and character-frequency manipulation to determine anagram similarity.

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
Sep 6, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
1
0

You are given two independent tasks.

Task A (Maximize calories over jumps):

  • There are n blocks with integer heights height[i] ≥ 0.
  • You start on the ground at height 0. You must visit every block exactly once in any order. After the first jump from the ground to some block, you may only jump between blocks; you cannot return to the ground.
  • The calories consumed for a jump from a location of height x to a location of height y is (x − y)^2 (the ground’s height is 0).
  • Choose an order of visiting the n blocks that maximizes the total calories across all n jumps (ground → first block plus the n−1 subsequent block-to-block jumps). Return the maximum total as an integer.
  • Example: n = 3, height = [5, 2, 5] ⇒ 43.
  • Describe your algorithm and analyze its time and space complexity.

Task B (Password similarity under character-removal):

  • For each test case, you are given two lowercase strings password1 and password2.
  • You may remove all occurrences of at most one chosen character from password1, and independently remove all occurrences of at most one chosen character from password2. You may also choose to remove nothing from either string.
  • After these removals, the strings are considered similar if they are anagrams (i.e., they have identical character multisets).
  • For each test case, return true if the strings can be made similar under this rule, otherwise return false.
  • Example: password1 = "safddadfs", password2 = "famafmss" ⇒ true (remove all 'd' from password1 and all 'm' from password 2).
  • Describe your algorithm and analyze its time and space 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.