Himanshu Goyaldsa-patterns-prefix-sum-with-hashmap.hashnode.dev·Dec 17, 2024DSA Patterns: Prefix Sum with Hash Map Technique ✨✨✨Welcome to the first article in our DSA Patterns series, where we discuss commonly used patterns to solve coding problems, particularly for interviews. In this blog, we will break down the Prefix Sum with Hash Map technique—a powerful approach for so...dsapatterns
Saumyaa Gargsaumyaagarg.hashnode.dev·Dec 13, 2024Day 17: Prefix Sum and Two PointersWelcome to Day 17 of my 100 Days of DSA challenge! Today, I explored two essential techniques: Prefix Sum and Two Pointers. These techniques are incredibly efficient for solving problems related to subarray sums and optimized array traversal. The pro...10 likesWeek 3DSA
Syed Taha Kamal Ahmadsyedtahakamalahmad.hashnode.dev·Oct 28, 2024Resolution Time - Code Optimization Problem FixCode Optimization Method 1 : Least Optimized Method : If you look closely I have added three nested for loops in here, of course this is not going to be a very optimal solution (Hence the execution time is higher) var resolutionTimeList = []; var inc...28 readscodeoptimiztion
Vishad Patelvishad.hashnode.dev·Aug 17, 2024Solving the DSA Prefix Sum Product Array PuzzleProblem Statement Given an array of integers A, let's find and return a new array of the same size. In this new array, each element at index i will be the product of all the elements in the original array except the one at i. Note: You can always cre...DSA Problem And SolutionDSA
Vishad Patelvishad.hashnode.dev·Aug 11, 2024Prefix Sum - Find number of Event number count - LeetcodeGiven an array of size N and Q queries, where each query is represented as a pair (s, e), the task is to determine the number of even elements within the specified index range from s to e for each query. Specifically, for each query, we need to count...DSA Problem And Solutionleetcode
Jay Choukseyjayjava.hashnode.dev·Jul 14, 2024Find the Highest AltitudeIntroduction Today, I tackled an interesting problem from LeetCode 75: Find the Highest Altitude. This easy-level question requires knowledge of arrays and prefix sums. It involves finding the highest altitude reached during a biker's road trip. Let'...Java
Tapan Rachchhtapanrachchh.hashnode.dev·Jun 10, 2024974. Subarray Sums Divisible by Kclass Solution: def subarraysDivByK(self, nums: List[int], k: int) -> int: prefixSum = 0 ans = 0 reminders = {} reminders[0] = [1] for i, num in enumerate(nums): prefixSum += num m ...Python
Gulshan Kumarperfinsights.hashnode.dev·May 26, 2024Find the Highest AltitudeThere is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0. You are given an integer array gain of length n where gain[i] is the net gain in altitud...Java SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·May 18, 2024Maximum Score After Splitting a StringGiven a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring). The score after splitting a string is the number of zeros in the left substring plus the ...Java SolutionJava
Vibhu Agarwalvibhu4agarwal.hashnode.dev·Mar 16, 2024Leetcode #2448 Minimum Cost to Make Array EqualRead the question here: https://leetcode.com/problems/minimum-cost-to-make-array-equal/description/ Let the final array be [k, k, k, k, ...] (all the elements being equal to k) k has to be in the range between min(nums) and max(nums) If we can try ...data structures