AAAdiam Ahmedinadiamvsleetcode.hashnode.dev·May 19, 2025 · 7 min readLeetCode: Counting BitsProblem Link LeetCode Version Problem Statement Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i. Example: //Example 1: Input: n = 2 Output: [...00
AAAdiam Ahmedinadiamvsleetcode.hashnode.dev·May 17, 2025 · 5 min readRange Sum Query - ImmutableProblem Link LeetCode Version Problem Statement Given an integer array nums, handle multiple queries of the following type: Calculate the sum of the elements of nums between indices left and right inclusive where left <= right. Implement the NumA...00
AAAdiam Ahmedinadiamvsleetcode.hashnode.dev·May 16, 2025 · 8 min readBest Time to Buy and Sell StockProblem Link LeetCode Version Let’s be honest—“Best Time to Buy and Sell Stock” sounds like something you’d Google after watching The Wolf of Wall Street at 2 a.m. and convincing yourself you’re a financial genius. The good news? There’s a greedy a...00
AAAdiam Ahmedinadiamvsleetcode.hashnode.dev·May 14, 2025 · 6 min readClimbing Stairs LeetcodeProblem Link LeetCode Version NeetCode Version Problem Statement You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example: Input: n =...00
AAAdiam Ahmedinadiamvsleetcode.hashnode.dev·May 13, 2025 · 6 min readSingle NumberProblem Link LeetCode Version Problem Statement Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra s...00