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

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

Nilesh Saininileshsaini.hashnode.dev·May 30, 2023Find Pivot IndexThere are countless ways to approach this problem and optimize your solution. In this article, we’ll explore one of those strategies to tackle this problem. Let’s see the problem statement first. Problem Statement: Given an array of integers nums, c...Discuss·50 readsJavaScript

Nilesh Saininileshsaini.hashnode.dev·May 7, 2023Product of Array Except SelfThis problem challenges us to find the product of all elements in an array except for the current element, without using division. While the brute-force approach of computing the product of all elements and then dividing by each element is straightfo...Discuss·57 readsJavaScript

Siddharth Tambattechtronic.hashnode.dev·May 1, 2023The Magic of Prefix Array: Boosting Your Programming Skills📍Introduction A Prefix array is a simple yet effective tool in computer programming. It helps to minimize the repeated calculations done in an array and reduces the time complexity of your program. 📍What is a Prefix Array? A Prefix Sum Array is a c...Discuss·10 likes·124 readsData Structures & Algorithmsprefix-sum