shlogg · Early preview
Dev Nirwal @devn007

ML Researcher | Problem solver

Unique Characters In String: O(1) Space Complexity

Two approaches to find repeated char in string: frequency array & bit masking. Time complexity O(N), space complexity O(1). Code provided.

Max Absolute Sum With Kadane's Algorithm

Max subarray sum & min absolute sum using Kadane's algorithm. Time complexity O(N), space complexity O(1). Code: class Solution { public int maxAbsoluteSum(int[] nums) {...} }

Reversing The Second Half Of A Linked List In O(1) Space

Reorder a linked list by reversing the second half and combining it with the first half. Time complexity: O(N), Space complexity: O(1).

Efficient Stock Span Calculation With O(n) Time Complexity

Implement Stock Spanner with O(n) time complexity and O(n) space complexity. Use a list to store price and span, jumping to last day's span when current price is less than previous prices.

Optimizing Sorting Algorithm For Three Colors In O(N) Time Complexity

Sort colors in O(N) time complexity using counting sort. Initialize counters for zeros and ones, then place them in the array accordingly.

Optimized Solution To Set Matrix Zeroes In O(1) Space Complexity

Optimized solution to set zeros in a matrix. Use two boolean vars to track first row & col with zero, then iterate through rest of matrix to mark rows & cols with zero.