PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Akuna Capital

Count subarrays equal to target

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in array algorithms, cumulative-sum (prefix-sum) reasoning, and hash-based frequency techniques, including understanding how negative values affect subarray sums.

  • Medium
  • Akuna Capital
  • Coding & Algorithms
  • Data Scientist

Count subarrays equal to target

Company: Akuna Capital

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Given an integer array nums and an integer k, count the number of contiguous subarrays whose sum equals k. Solve it in O(n) time and O(n) space by maintaining a running prefix sum and a hash map of prefix-sum frequencies. Explain why this works with negative numbers, analyze complexity, and provide code or pseudocode.

Quick Answer: This question evaluates proficiency in array algorithms, cumulative-sum (prefix-sum) reasoning, and hash-based frequency techniques, including understanding how negative values affect subarray sums.

Related Interview Questions

  • Find minimum swaps to sort array with duplicates - Akuna Capital (hard)
  • Heapify an array into a max-heap - Akuna Capital (Medium)
  • Implement a ring buffer - Akuna Capital (Medium)
  • Compute max profit across dated stock quotes - Akuna Capital (Medium)
  • Break a palindrome to smallest non-palindrome - Akuna Capital (Medium)
Akuna Capital logo
Akuna Capital
Aug 10, 2025, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
1
0

Given an integer array nums and an integer k, count the number of contiguous subarrays whose sum equals k. Solve it in O(n) time and O(n) space by maintaining a running prefix sum and a hash map of prefix-sum frequencies. Explain why this works with negative numbers, analyze complexity, and provide code or pseudocode.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Akuna Capital•More Data Scientist•Akuna Capital Data Scientist•Akuna Capital Coding & Algorithms•Data Scientist 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.