ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Make Sum Divisible by P | Simplest Explanation | Full Dry Run | Leetcode 1590 | codestorywithMIK

Автор: codestorywithMIK

Загружено: 2024-10-03

Просмотров: 23530

Описание: Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 112th Video of our Playlist "Array 1D/2D : Popular Interview Problems" by codestorywithMIK

Similar Problems :
Leetcode - 1074 :    • Number of Submatrices That Sum to Target |...  
Leetcode - 974 :    • Subarray Sums Divisible by K | Brute Force...  

In this video we will try to solve a good Array Cumulative Sum related Problem : Make Sum Divisible by P | Simplest Explanation | Full Dry Run | Leetcode 1590 | codestorywithMIK

I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.

Problem Name : Make Sum Divisible by P | Simplest Explanation | Full Dry Run | Leetcode 1590 | codestorywithMIK
Company Tags : will soon update
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/make-su...


My DP Concepts Playlist :    • Roadmap for DP | How to Start DP ? | Topic...  
My Graph Concepts Playlist :    • Graph Concepts & Qns - 1 : Graph will no m...  
My Recursion Concepts Playlist :    • Introduction | Recursion Concepts And Ques...  
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Intervie...
Instagram :   / codestorywithmik  
Facebook :   / 100090524295846  
Twitter :   / cswithmik  
Subscribe to my channel :    / @codestorywithmik  

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

Summary :
The solution aims to find the smallest subarray that, when removed, makes the sum of the remaining array divisible by a given integer p. Here’s how it works:

Calculate Total Modulo: First, compute the total sum of the array modulo p. This determines the target remainder that needs to be removed to make the remaining sum divisible by p.

Early Exit: If the total sum is already divisible by p (target == 0), the function immediately returns 0, as no subarray needs to be removed.

Iterate through the Array:

Maintain a prefix sum (curr) modulo p while iterating through the array.
Use a hash map (map) to store the indices of seen remainders to efficiently find subarrays with a specific remainder.
Check for Subarray:

For each element, calculate the remainder remain that, if removed, would make the remaining sum divisible by p.
If this remainder has been seen before, update the result with the length of the smallest subarray.
Return Result:

If a valid subarray is found, return its length. Otherwise, return -1.
This approach leverages prefix sums and hash maps for efficient subarray length calculation, making it run in linear time O(n).


✨ Timelines✨
00:00 Introduction
00:21 Motivation
00:43 Similar Problems
01:29 Problem Explanation
03:26 Thought Process
15:03 Full Dry Run
22:50 Coding it up

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Make Sum Divisible by P | Simplest Explanation | Full Dry Run | Leetcode 1590 | codestorywithMIK

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Divide Players Into Teams of Equal Skill | With Proof | Dry Run | Leetcode 2491 | codestorywithMIK

Divide Players Into Teams of Equal Skill | With Proof | Dry Run | Leetcode 2491 | codestorywithMIK

Make Sum Divisible by P - Leetcode 1590 - Python

Make Sum Divisible by P - Leetcode 1590 - Python

Subarray Sum Equals K (LeetCode 560) | Interview Essential | Prefix Sum

Subarray Sum Equals K (LeetCode 560) | Interview Essential | Prefix Sum

Сделайте сумму делимой на P | LeetCode 1590 | Полное интуитивное объяснение

Сделайте сумму делимой на P | LeetCode 1590 | Полное интуитивное объяснение

Make Sum Divisible by P | Leetcode 1590 | Java Hindi

Make Sum Divisible by P | Leetcode 1590 | Java Hindi

Что такое «Вайбкодинг» и почему ваш стартап развалится через неделю

Что такое «Вайбкодинг» и почему ваш стартап развалится через неделю

Subarray Sums Divisible by K | Brute Force | Optimal | Easy Explanation | codestorywithMIK

Subarray Sums Divisible by K | Brute Force | Optimal | Easy Explanation | codestorywithMIK

Шаблоны для собеседования по программированию — Префиксная сумма | 10 различных проблем в одном в...

Шаблоны для собеседования по программированию — Префиксная сумма | 10 различных проблем в одном в...

Сделать сумму делимой на P — Leetcode 1590 — Python

Сделать сумму делимой на P — Leetcode 1590 — Python

Subarray Sum Equals K - Prefix Sums - Leetcode 560 - Python

Subarray Sum Equals K - Prefix Sums - Leetcode 560 - Python

Мой мозг после 569 проблем с Leetcode

Мой мозг после 569 проблем с Leetcode

Find Kth Bit in Nth Binary String | Detailed Recursion | Dry Run | Leetcode 1545 | codestorywithMIK

Find Kth Bit in Nth Binary String | Detailed Recursion | Dry Run | Leetcode 1545 | codestorywithMIK

Алгоритмы и структуры данных за 15 минут! Вместо 4 лет универа

Алгоритмы и структуры данных за 15 минут! Вместо 4 лет универа

Minimum Cost Path with Teleportations | 3 Approaches | Postmortem | Leetcode 3651 | codestorywithMIK

Minimum Cost Path with Teleportations | 3 Approaches | Postmortem | Leetcode 3651 | codestorywithMIK

1590. Make Sum Divisible by P | Leetcode Daily (POTD) 3 Oct 2024 | Meidum | Java | Hindi

1590. Make Sum Divisible by P | Leetcode Daily (POTD) 3 Oct 2024 | Meidum | Java | Hindi

Arrays (1-D & 2-D) : Popular Interview Problems

Arrays (1-D & 2-D) : Popular Interview Problems

Increasing Triplet Subsequence -(Amazon, Walmart, Facebook): Explanation ➕ Live Coding 🧑🏻‍💻

Increasing Triplet Subsequence -(Amazon, Walmart, Facebook): Explanation ➕ Live Coding 🧑🏻‍💻

Animation vs. Coding

Animation vs. Coding

Давайте взломаем/обратно проведем инженерный анализ вашей первой программы

Давайте взломаем/обратно проведем инженерный анализ вашей первой программы

Subarray Sums Divisible by K - Leetcode 974 - Python

Subarray Sums Divisible by K - Leetcode 974 - Python

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]