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

Find All Possible Recipes From Given Supplies

Filter valid recipes with ingredients in supplies or other recipes, build dependency graph, and use topological sorting to process recipes in order, ensuring all dependencies are met.

Divide Array Into Equal Pairs: Check Even Counts

Can an array be divided into pairs where each pair has equal elements? Count frequencies, check if all are even. If yes, return true; otherwise, false.

Closest Prime Numbers In Range [left, Right]

Here's the summary of the blog post in 250 characters or less: "Find closest prime numbers within range [left, right]. Use Sieve of Eratosthenes to generate primes up to right value. Collect primes in range and find pair with min difference.

Count Colored Cells With 2n^2 - 2n + 1 Formula

Count Total Number of Colored Cells: Use formula 2n^2 - 2n + 1 to calculate colored cells after n minutes. Each minute adds 4*(k-1) new cells, forming an arithmetic sequence.

Can A Number Be Represented As Sum Of Powers Of Three?

n can be sum of distinct powers of 3 if ternary rep only contains 0 & 1. Convert n to base 3, check for digit 2. If found, return false. Otherwise, true.

Maximum Absolute Sum Of Any Subarray

Maximum Absolute Sum of Any Subarray: Use Kadane's algorithm to find max & min subarray sums. Result = max(abs(max sum), abs(min sum)). Efficiently computes result in linear time.

Number Of Sub-arrays With Odd Sum In Array

Count subarrays with odd sum using prefix sums & parity tracking. For each index, add count of opposite parity prefix sums to result. Update counts & take modulo 10^9 + 7 for large inputs.

Construct Binary Tree From Preorder And Postorder Traversal

Construct binary tree from preorder and postorder traversal using recursion. Identify root as first element in preorder, split arrays based on left child position in postorder, and recursively construct left and right subtrees.

Recover Binary Tree From Preorder Traversal In 60 Characters

Recover binary tree from preorder traversal string: parse dashes for depth & build tree with stack-based approach, ensuring left children are prioritized.

Constructing Unique Binary String From Given Array

Find Unique Binary String: Construct a binary string that differs from every string in nums by flipping each bit. O(n) time complexity. Example inputs and outputs provided.

The K-th Lexicographical String Of All Happy Strings Of Length N

Generate all happy strings of length n in lexicographical order and return the k-th string. Use backtracking to build strings character by character, ensuring each new char is different from the previous one.

Letter Tile Possibilities Calculator

1079. Letter Tile Possibilities: Use backtracking DFS to generate all possible permutations of tiles for lengths 1 to n. Manage counts with frequency map to avoid duplicates. Complexity manageable due to input length constraint.

Constructing Lexicographically Largest Valid Sequence For N

Construct Lexicographically Largest Valid Sequence: Use backtracking to build sequence with numbers 1-n twice, distance between occurrences equal to value. Reserve positions for subsequent occurrences.

Find Punishment Number Of An Integer In 60 Characters

Iterate through integers 1-n, compute square and check if it can be partitioned into substrings that sum up to the integer using recursive helper function.

Remove All Occurrences Of A Substring In PHP

Iterative removal of substring part from string s until no occurrences remain. Repeatedly find and remove leftmost occurrence of part, checking resulting string for new occurrences. Time complexity: O(n^2) in worst case.

Clear Digits From String In O(n) Time Complexity

Clear Digits: Remove all digits from a string by deleting each digit and its closest non-digit char to left. Use stack to track non-digits & pop top element when digit encountered.

Counting Bad Pairs In An Array

Count bad pairs in array nums by calculating total pairs (n*(n-1)/2) and subtracting good pairs (sum of m*(m-1)/2 for each group with m elements). Use a frequency map to count occurrences of each value (nums[i] - i).

Efficient Color Tracking In Software Engineering And Web Dev

Use two HashMaps: colorMap & colorCount to track ball colors & counts. Update counts after each query, removing colors with 0 balls. Result is size of colorCount after each query.

One String Swap Can Make Strings Equal In 60 Characters

Return true if two strings can be equal by swapping at most one character in one string. Check if exactly two indices differ and swap would make them equal. Time complexity: O(n).

Special Array I: Check Adjacent Pairs For Different Parity

Special Array I: An array is special if every pair of adjacent elements has different parity (one even, one odd). Check length, iterate through array, and compare parities. Return true if all pairs have different parities.

Making A Large Island In Grid After Changing At Most One 0 To 1

Identify islands with DFS/BFS, calculate sizes & store in dict/array. For each 0, check neighbors & calc potential new island size. Return max size found or largest island if no 0s.

Find Eventual Safe States In Graphs

eventualSafeNodes function returns an array of safe nodes in a directed graph, sorted in ascending order. It uses DFS to detect cycles and classify nodes as safe or unsafe.

Find Eventual Safe States In Graphs

eventualSafeNodes function returns an array of safe nodes in a directed graph, sorted in ascending order. It uses DFS to detect cycles and classify nodes as safe or unsafe.

Counting Communicating Servers In Grids

Two servers can communicate if they're in the same row or column. Count servers that can talk to others by counting rows and columns with multiple servers.

Building A Simple Weather App With GitHub Copilot

Built a lightweight web app using OpenWeatherMap API, displaying current weather & 5-day forecast for any city worldwide. GitHub Copilot helped with code autocompletion, debugging assistance & UI integration

First Completely Painted Row Or Column In Matrix

Pre-process matrix positions in O(m*n) time. Traverse arr, updating row and column frequencies. Return index where either row or column is fully painted. Time complexity: O(m*n). Space complexity: O(m*n).

Minimum Cost To Make At Least One Valid Path In A Grid

Modify signs in m x n grid to create a valid path from top-left to bottom-right using 0-1 BFS with deque & distance array, achieving min cost of O(m × n) time & space complexity.

Neighboring Bitwise XOR: Valid Binary Array Existence

The XOR of all elements in derived must equal 0 for a valid original array to exist. If the result is 0, return true; otherwise, return false.

Bitwise XOR Of All Pairings In O(m + N) Time Complexity

Bitwise XOR of All Pairings: Return the bitwise XOR of all integers in nums3, where nums3 contains the XOR of all pairings between nums1 and nums2.

Find Prefix Common Array Of Two Arrays

We can solve this problem by iterating over two arrays A and B while keeping track of numbers that have occurred at or before the current index in both arrays using two hash sets (or arrays).

Integrating PHPUnit Tests In Laravel Development Workflow

Get started with PHPUnit in Laravel: Install, configure, write & run tests. Integrate into your dev workflow using CI/CD tools like GitHub Actions or Jenkins. Track code coverage with Xdebug.

Can A Parentheses String Be Valid With Locked Indices?

A string is valid if it's empty or can be written as AB where A and B are valid strings, or (A) where A is a valid string. Given a string s and locked string, return true if s can be made valid.

Maximizing Word Scores With Letter Constraints

Maximizing word scores with bitmasking and letter counts. Code generates all subsets of words, checks validity, and calculates score for each subset. Time complexity is O(2n × w), where n is the number of words and w is max word length.

Minimum Remove To Make Valid Parentheses

Remove min parentheses to make valid string: remove unnecessary ( and ) while keeping valid chars. Two-pass approach: first pass removes invalid closing ), second pass removes invalid opening (.

Path With Maximum Gold Problem Solution In PHP

DFS with backtracking finds max gold in grid by exploring all paths, adding current cell's gold to next valid positions' max gold. Time complexity: O(m * n).

Counting Nice Subarrays With Sliding Window And Prefix Sums

The problem requires finding the number of subarrays in an integer array that contain exactly k odd numbers. A sliding window approach with prefix sums efficiently counts these "nice" subarrays.

Can Construct K Palindrome Strings From Given String

Construct K Palindrome Strings: Use hash table to count char frequencies & odd counts. If k > len(s) or odd counts > k, return false. Otherwise, true.

Word Subsets In PHP: Finding Universal Strings

Find universal strings in words1 where each string in words2 is a subset. Count max char freq in words2 & check each word in words1. Return universal words.

Counting Prefix And Suffix Pairs In Strings

Iterate through all index pairs (i, j) where i < j, check if words[i] is both prefix and suffix of words[j] using PHP's substr() function, return total count of true pairs.

String Matching In Array: Find Substrings

Find all strings in an array that are substrings of another word using brute force or KMP algorithm. PHP solution: loop through words, compare each with others using strpos() function.

Reverse Substrings Between Each Pair Of Parentheses

Reverse strings between each pair of parentheses: use stack to track chars & nested parens. Pop & reverse substrings when closing parenthesis encountered. Concatenate stack contents for result.

Minimum Number Of Operations To Move All Balls To Each Box

We can use a prefix sum approach to calculate the minimum number of operations needed to move all balls to each box without simulating each operation. The solution runs in O(n) time and has a space complexity of O(n).

Shifting Letters II: Efficient String Shifting With Prefix Sum

We need to avoid shifting characters one by one for each shift, so we use prefix sum to efficiently apply cumulative shifts to each character in the string.

Unique Length-3 Palindromic Subsequences In Strings

We can use an efficient algorithm that leverages prefix and suffix character tracking to count all valid palindromic subsequences in O(n) time complexity.

Number Of Ways To Split Array In PHP

Prefix sum and total sum are computed for efficient comparisons. Iterate over array, checking if prefix sum is >= remaining sum (total sum - prefix sum). Time complexity: O(n), space complexity: O(1).

Maximizing Satisfied Customers With Sliding Window Technique

Here is the summary in 250 characters: "Maximize customer satisfaction by making grumpy owners happy for `minutes` minutes. Use sliding window approach to find max possible satisfaction.

1051 Height Checker: Counting Mismatches In Student Heights

heightChecker function efficiently calculates the number of indices where heights are out of place compared to expected order, with time complexity O(n log n) due to sorting.

Count Vowel Strings In Ranges With PHP Solution

Counting vowel strings in ranges: precompute prefix sum of vowel strings, use unordered_set for vowels, and subtract prefix sum for range [l-1, r] to find count. Complexity: O(n + q).

Maximum Score After Splitting A String: Optimal Solution In PHP

Precompute prefix sum of ones in string s. Iterate over possible splits, counting zeros in left substring and using prefix sum for right substring. Update max score as the sum of zeros in left part and ones in right part. Return max score found.

Counting Good Strings In Dynamic Programming

Dynamic Programming solution for "Count Ways To Build Good Strings" problem: calculate dp[i] as sum of dp[i-zero] and dp[i-one], with base case dp[0]=1. Return dp[low] + ... + dp[high] modulo 10^9+7.

Number Of Ways To Form A Target String Given A Dictionary

Dynamic Programming solution for "Number of Ways to Form a Target String Given a Dictionary" implemented in PHP using memoization to efficiently count the number of ways to form the target string.

Maximum Sum Of 3 Non-Overlapping Subarrays In PHP

We use dynamic programming to find 3 non-overlapping subarrays of length k with max sum in an array nums, returning the lexicographically smallest solution if multiple exist.

Best Sightseeing Pair: Max Score In O(n) Time

Maximize sightseeing score: values[i] + values[j] - (j-i). Use single-pass approach with maxI and maxScore. O(n) time complexity, O(1) space complexity.

Longest Square Streak In Array: Finding Squares And Tracking Lengths

Find longest square streak in array: sort nums, use set for quick lookup, iterate through array & track max length. Time complexity O(n log n), space complexity O(n).

Check If N And Its Double Exist In Array

Check if N and its double exist in an array using a hash table. Iterate through the array, checking for each element if its double or half has been encountered. Return true if found, false otherwise.

Longest Special Substring Occurs Thrice In String

Find longest special substring that occurs thrice: iterate over lengths, extract substrings, count occurrences & check if special. Return length or -1 if no special substring found.

Make String A Subsequence Using Cyclic Increments

Two pointers i and j are used to check if str2 is a subsequence of str1 with at most one cyclic increment operation. If characters match or can be incremented cyclically, both pointers move forward.

PHP Streams For Efficient Large Dataset Processing

PHP streams efficiently handle large datasets & complex data processing tasks, offering memory efficiency, flexibility & asynchronous processing. Use fopen(), fgetcsv() & stream filters for CSV processing.

Setting Up CI/CD Pipelines For Laravel Projects With Docker & Jenkins

Automate your Laravel project's code testing & deployment with CI/CD pipelines using GitHub, Jenkins, and Docker. Follow this step-by-step guide to streamline your development process.

Take K Of Each Character From Left And Right In Minimum Time

Take K of Each Character From Left and Right: Use sliding window technique with two pointers to find min minutes needed to take at least k of each char ('a', 'b', 'c') from left & right of string.

Shortest Subarray With Sum At Least K

Given an array and an integer k, return the length of the shortest subarray with sum at least k. Use prefix sums and a monotonic queue for efficient solution.

Counting Fair Pairs In An Array With Binary Search And Sorting

Count fair pairs in array nums with lower <= nums[i] + nums[j] <= upper. Sort nums, use binary search for bounds & count valid indices.

Integrating Stripe Treasury API With PHP For Financial Services

Integrate Stripe Treasury API with PHP: Install SDK, set up account & keys, create financial accounts, fund & transfer funds, monitor transactions. Follow 8 steps for seamless integration.