PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Capital One

Count ordered fragment pairs forming a password

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency with string manipulation, handling duplicate fragments, and combinatorial reasoning about ordered index pairs that concatenate to a target, reflecting algorithmic problem-solving and correctness under index distinctness constraints.

  • medium
  • Capital One
  • Coding & Algorithms
  • Machine Learning Engineer

Count ordered fragment pairs forming a password

Company: Capital One

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

You are given: - A target string `password`. - A list of `N` string fragments `fragments[0..N-1]` (fragments may repeat). Count the number of **ordered pairs of distinct indices** `(i, j)` such that: `fragments[i] + fragments[j] == password` Notes: - “Ordered” means `(i, j)` and `(j, i)` are counted separately when both satisfy the condition. - Indices must be distinct (`i != j`). **Input:** `password`, `fragments`. **Output:** an integer count (potentially large; specify/assume 64-bit). State any constraints you assume and handle duplicates correctly.

Quick Answer: This question evaluates proficiency with string manipulation, handling duplicate fragments, and combinatorial reasoning about ordered index pairs that concatenate to a target, reflecting algorithmic problem-solving and correctness under index distinctness constraints.

Related Interview Questions

  • Solve Four Coding Assessment Tasks - Capital One (medium)
  • Write SQL using joins and window functions - Capital One (medium)
  • Review Preprocessing Code and Tests - Capital One (easy)
  • Remove nodes with a given value - Capital One (medium)
  • Solve multiple algorithmic interview questions - Capital One (hard)
Capital One logo
Capital One
Jan 20, 2026, 12:00 AM
Machine Learning Engineer
Take-home Project
Coding & Algorithms
4
0
Loading...

You are given:

  • A target string password .
  • A list of N string fragments fragments[0..N-1] (fragments may repeat).

Count the number of ordered pairs of distinct indices (i, j) such that:

fragments[i] + fragments[j] == password

Notes:

  • “Ordered” means (i, j) and (j, i) are counted separately when both satisfy the condition.
  • Indices must be distinct ( i != j ).

Input: password, fragments.

Output: an integer count (potentially large; specify/assume 64-bit).

State any constraints you assume and handle duplicates correctly.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Capital One•More Machine Learning Engineer•Capital One Machine Learning Engineer•Capital One Coding & Algorithms•Machine Learning 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.