shlogg · Early preview
Md Ariful Haque @mah-shamim

I am a Technical Lead with holistic knowledge of software development and design. I am also experienced in coordinating with stakeholders

Fraction Addition And Subtraction In PHP

Add fractions with PHP: parse input string, compute result step by step, simplify final fraction. gcd function & addFractions function used for simplification.

Strange Printer In Minimum Turns

Strange Printer problem: use dynamic programming to find min turns to print string s. Initialize dp[i][i] = 1, then fill table with same or different char logic. Result: dp[0][$n - 1]. Efficiently calculates min turns.

Palindrome Partitioning In PHP: All Possible Palindrome Partitions

Partitioning a string into palindromes: [["a","a","b"],["aa","b"]]. Use backtracking & dynamic programming to explore all possible partitions, checking each for being a palindrome.

Summing Root-to-Leaf Numbers In Binary Tree

Sum Root to Leaf Numbers: Use DFS to traverse binary tree & calculate sum of root-to-leaf numbers. Example inputs: [1,2,3] & [4,9,0,5,1]. Output: 25 & 1026 respectively.

Maximal Rectangle Area In Binary Matrix

Maximal Rectangle problem: find largest rectangle containing only 1's in binary matrix. Use dynamic programming & stack-based approach to calculate maximal area.

Binary Search For Kth Smallest Pair Distance In PHP

Find K-th Smallest Pair Distance: Sort nums, use binary search & two-pointer technique. Count pairs with distance ≤ mid, adjust search range. Time complexity: O(n log(max(nums) - min(nums)) + n log n)

Magic Squares In Grid: Counting 3x3 Contiguous Magic Square Subgrids

Counting Magic Squares In Grid: Given a grid of integers, find how many 3x3 contiguous magic square subgrids are there. A magic square has rows, columns & diagonals summing to same value with distinct numbers from 1 to 9.

Sort Colors In One Pass With Constant Extra Space

Sort Colors: Use Dutch National Flag algorithm with constant extra space. Initialize low, mid, high pointers. Swap nums[mid] with nums[low] if 0, move mid if 1, swap with nums[high] if 2. Continue until mid > high.