PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Capital One

Count ordered pairs that concatenate to target

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to manipulate string and numeric representations, perform efficient counting, and leverage associative data structures to identify matching concatenations.

  • medium
  • Capital One
  • Coding & Algorithms
  • Software Engineer

Count ordered pairs that concatenate to target

Company: Capital One

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

Given a list of integers `numbers` and an integer `target`, count the number of **ordered pairs** `(i, j)` with `i != j` such that concatenating `numbers[i]` followed by `numbers[j]` (in base-10) produces exactly `target`. More precisely, treat each integer as its usual base-10 string without extra leading zeros (e.g., `12 -> "12"`). Count pairs where: `str(numbers[i]) + str(numbers[j]) == str(target)`. Return the total count. ## Example - `numbers = [1, 212, 12, 12]`, `target = 1212` Valid ordered pairs: - `(0, 1)`: `"1" + "212" = "1212"` - `(2, 3)`: `"12" + "12" = "1212"` - `(3, 2)`: `"12" + "12" = "1212"` Return `3`. ## Assumptions / Constraints - Assume all integers are non-negative. - `1 ≤ len(numbers) ≤ 2e5` (you should aim for better than `O(n^2)` if possible). - Values fit in 32-bit signed integers.

Quick Answer: This question evaluates a candidate's ability to manipulate string and numeric representations, perform efficient counting, and leverage associative data structures to identify matching concatenations.

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

Given a list of integers numbers and an integer target, count the number of ordered pairs (i, j) with i != j such that concatenating numbers[i] followed by numbers[j] (in base-10) produces exactly target.

More precisely, treat each integer as its usual base-10 string without extra leading zeros (e.g., 12 -> "12"). Count pairs where:

str(numbers[i]) + str(numbers[j]) == str(target).

Return the total count.

Example

  • numbers = [1, 212, 12, 12] , target = 1212

Valid ordered pairs:

  • (0, 1) : "1" + "212" = "1212"
  • (2, 3) : "12" + "12" = "1212"
  • (3, 2) : "12" + "12" = "1212"

Return 3.

Assumptions / Constraints

  • Assume all integers are non-negative.
  • 1 ≤ len(numbers) ≤ 2e5 (you should aim for better than O(n^2) if possible).
  • Values fit in 32-bit signed integers.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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