Count Subarray sum Equals K | Brute - Better -Optimal

Description

Problem Link: http://bit.ly/3Kn10eZ

Please watch this video before watching this one: https://www.youtube.com/watch?v=frf7qxiN2qU

Notes/C++/Java/Python codes: https://takeuforward.org/arrays/count-subarray-sum-equals-k/

We have solved the problem, and we have gone from brute force and ended with the most optimal solution. Every approach's code has been written in the video itself. Also, we have covered the algorithm with intuition.

Full Course: https://bit.ly/tufA2ZYt

You can follow me across social media, all my handles are below:

Linkedin/Instagram/Telegram: https://linktr.ee/takeUforward

00:00 Intro

01:03 Problem Statement

01:13 Sub-array definition

01:52 Example

03:13 Brute force solution

06:07 Complexity

06:29 Better solution

08:07 Complexity

08:21 Optimal Solution

08:41 Prefix sum concept

09:35 Thought process

13:55 Dry run

21:22 Code

22:38 Complexity

Designed under CodEX ©2025 Nexus

Designed under CodEX ©2025 Nexus

Designed under CodEX ©2025 Nexus