---
title: "Discussion on \"LeetCode 560. Subarray Sum Equals K - From Intuitive O(n²) to Optimized O(n) solution using HashMap(Med, Java)\" | Hashnode"
description: "Discussion on \"LeetCode 560. Subarray Sum Equals K - From Intuitive O(n²) to Optimized O(n) solution using HashMap(Med, Java)\". Problem Statement\n\nLeetCode 560. Subarray Sum Equals K\n\nGiven an integer array nums and an integer k, return the total number of continuous subarrays whose sum is equal to k.\nExample:\n\nInput: nums = [1,1,1], k = 2\nOutput: 2 (subarrays [1,1] at indice..."
url: "https://hashnode.com/posts/leetcode-560-subarray-sum-equals-k-from-intuitive-on-to-optimized-on-solution-using-hashmapmed-java/6878b66f08ff986353c9ac2d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [LeetCode 560. Subarray Sum Equals K - From Intuitive O(n²) to Optimized O(n) solution using HashMap(Med, Java)](https://huanganni.hashnode.dev/leetcode-560-subarray-sum-equals-k-from-intuitive-on-to-optimized-on-solution-using-hashmapmed-java?utm_source=hashnode&utm_medium=feed)

Problem Statement LeetCode 560. Subarray Sum Equals K Given an integer array nums and an integer k, return the total number of continuous subarrays whose sum is equal to k. Example: Input: nums = \[1,1,1\], k = 2 Output: 2 (subarrays \[1,1\] at indice...

Jul 17, 2025 · 3 min read · huanganni.hashnode.dev  
Read the article

-   [#leetcode](https://hashnode.com/tag/leetcode)
-   [#leetcode-medium](https://hashnode.com/tag/leetcode-medium)
-   [#leetcode-solution](https://hashnode.com/tag/leetcode-solution)
-   [#array](https://hashnode.com/tag/array)
-   [#java](https://hashnode.com/tag/java)
-   [#hashmap](https://hashnode.com/tag/hashmap)
-   [#hashmaps](https://hashnode.com/tag/hashmaps)

## Written by

[Anni Huang](https://hashnode.com/@HuangAnni)

@HuangAnni · Singapore

  
[View profile](https://hashnode.com/@HuangAnni)

LLM Training Operation Specialist @ ByteDance | Ex-Master of IT in Business (AI track) at SMU

I’m Anni Huang, an AI researcher-in-training currently at ByteDance, specializing in LLM training operations with a coding focus. I bridge the gap between engineering execution and model performance, ensuring the quality, reliability, and timely delivery of large-scale training projects.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
