In this video, we solve Leetcode 1018. Binary Prefix Divisible By 5 using Java.
Question Link - https://leetcode.com/problems/binary-prefix-divisible-by-5/description/?envType=daily-question&envId=2025-11-24
Solution: https://github.com/deepak-sharma-iOS/Leetcode-Daily-Challenge/blob/main/Leetcode-1018.java
Summary:
This solution recursively tries picking or skipping each number while tracking the current sum’s remainder modulo 3.
It returns only sums that end with remainder 0 and uses a DP table (`dp[index][rem]`) to store the best result from each state.
This avoids recalculations and finds the maximum divisible-by-3 sum.
Subscribe - https://www.youtube.com/@DebugWithDeepak
Github - https://github.com/deepak-sharma-iOS/Leetcode-Daily-Challenge
Linkedin - https://www.linkedin.com/in/deepak-sharmaa-dev/
#CodeWithDeepak #LeetCodeDailyChallenge #LeetCodeSolutions #DSAforInterviews #CodingWithExplanation #TechInterviewPrep #CrackTheCodingInterview #DailyCodingChallenge #JavaCoding #LearnToCode #CodingShorts #leetcodedailychallenge #euclidean
Download
0 formats
No download links available.
Binary Prefix Divisible By 5 | Leetcode 1018 | DSA | HIndi Explaination | Code With Deepak | NatokHD