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...DiscussDSA 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...DiscussDSA 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'...DiscussJava
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 ...DiscussPython
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...DiscussJava 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 ...DiscussJava 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 ...Discussdata structures
Sambhav Ranasambhavnrana.hashnode.dev·Feb 4, 2024Arrays: Types and Essential Algorithmic TechniquesArrays are fundamental data structures in computer programming, serving as the building blocks for numerous algorithms and applications. Whether you're a beginner programmer or an experienced developer preparing for coding interviews, a solid underst...Discuss·9 likesarray
Gulshan Kumarperfinsights.hashnode.dev·Jan 20, 2024Product of Array Except SelfGiven an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algori...DiscussJava Solutionarray
Akarsh Jainakarshjain.hashnode.dev·Aug 29, 2023The Prefix Sum: A Simple but Efficient Data StructureIf you've started to venture into the world of programming, you might have come across situations where you need to work with parts of a list, even though you might not realize it just yet. No worries if this sounds new – I'm here to walk you through...Discuss#PrefixSum