PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates proficiency in fundamental algorithmic problem-solving, specifically array manipulation, string processing, and the use of basic data structures along with performance and complexity reasoning.

  • medium
  • Amazon
  • Coding & Algorithms
  • Data Scientist

Solve Algorithmic Challenges in Online Coding Assessments

Company: Amazon

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

##### Scenario Online assessment requiring implementation of common algorithmic problems. ##### Question Given an array of integers and a target, return indices of the two numbers that add up to the target (assume exactly one solution). 2) Given a string, determine the length of the longest substring without repeating characters. ##### Hints Use hash maps for O(n) solutions; mind edge cases like empty input.

Quick Answer: This question evaluates proficiency in fundamental algorithmic problem-solving, specifically array manipulation, string processing, and the use of basic data structures along with performance and complexity reasoning.

Two Sum

Given an array of integers `nums` and an integer `target`, return the indices of the two numbers such that they add up to `target`. You may assume that each input has exactly one solution, and you may not use the same element twice. Return the answer as a list of the two indices `[i, j]` with `i < j`. Example 1: Input: nums = [2, 7, 11, 15], target = 9 Output: [0, 1] (because nums[0] + nums[1] == 9) Example 2: Input: nums = [3, 2, 4], target = 6 Output: [1, 2] Use a hash map to achieve an O(n) single-pass solution.

Constraints

  • 2 <= len(nums) <= 10^4
  • -10^9 <= nums[i] <= 10^9
  • -10^9 <= target <= 10^9
  • Exactly one valid answer exists.

Examples

Input: ([2, 7, 11, 15], 9)

Expected Output: [0, 1]

Explanation: nums[0] + nums[1] = 2 + 7 = 9.

Input: ([3, 2, 4], 6)

Expected Output: [1, 2]

Explanation: nums[1] + nums[2] = 2 + 4 = 6; note nums[0]=3 alone cannot reuse itself.

Hints

  1. A brute-force O(n^2) approach checks every pair, but you can do better.
  2. As you iterate, store each number's index in a hash map.
  3. For each number, check whether target - number is already in the map; if so you have your pair.

Longest Substring Without Repeating Characters

Given a string `s`, find the length of the longest substring that contains no repeating characters. A substring is a contiguous sequence of characters within the string. Example 1: Input: s = "abcabcbb" Output: 3 (the answer is "abc", with length 3) Example 2: Input: s = "bbbbb" Output: 1 (the answer is "b") Example 3: Input: s = "pwwkew" Output: 3 (the answer is "wke"; note "pwke" is a subsequence, not a substring) Use a sliding window with a hash map of last-seen indices for an O(n) solution.

Constraints

  • 0 <= len(s) <= 5 * 10^4
  • s consists of English letters, digits, symbols, and spaces.

Examples

Input: ("abcabcbb",)

Expected Output: 3

Explanation: The longest unique substring is "abc" with length 3.

Input: ("bbbbb",)

Expected Output: 1

Explanation: Every character repeats; the best window is a single "b".

Hints

  1. Maintain a sliding window [start, i] that always contains only unique characters.
  2. Track the most recent index where each character was seen in a hash map.
  3. When you encounter a repeat that lies inside the current window, jump start to one past its previous index.
Last updated: Jun 25, 2026

Loading coding console...

PracHub

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding 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.

Related Coding Questions

  • Find a Maximum-Sum Window in a Sparse Array - Amazon (hard)
  • Find Two-Word Compound Words - Amazon (hard)
  • Unify Stock-Trading Profit Variants - Amazon (easy)
  • Implement Regular Expression Matching - Amazon (easy)
  • Minimum Path Length Through a Grid With One Allowed Cell Conversion - Amazon (medium)