LeetCode 2841: Maximum Sum of Almost Unique Subarray

LeetCode 2841: Maximum Sum of Almost Unique Subarray Summary Given an array, window size k, and threshold m, find the maximum sum of any length-k subarray that contains at least m distinct elements. Approach Use a sliding window with a frequency map, track window sum and number of distinct values. Complexity Time: O(n) Space: O(n) for frequency map Python reference implementation def max_sum_almost_unique(nums, m, k): from collections import defaultdict count = defaultdict(int) distinct = 0 window_sum = 0 ans = 0 for i, x in enumerate(nums): window_sum += x if count[x] == 0: distinct += 1 count[x] += 1 if i >= k: y = nums[i - k] window_sum -= y count[y] -= 1 if count[y] == 0: distinct -= 1 if i >= k - 1 and distinct >= m: ans = max(ans, window_sum) return ans

December 4, 2025 · 1 min · map[name:Jeanphilo]

Sorting Series (4): Merge Sort - Stable Divide and Conquer and External Sorting

Systematic explanation of merge sort principles, stability, space trade-offs, and engineering scenarios with Python/C/C++/Go/Rust/JS implementations and external sorting guidance.

December 4, 2025 · 10 min · map[name:Jeanphilo]

Sorting Series (3): Shell Sort - From Insertion to Gap-Based Efficiency

Explain Shell sort principles, gap strategies, and engineering usage with scenarios and Python/C/C++/Go/Rust/JS implementations.

December 3, 2025 · 7 min · map[name:Jeanphilo]

Sorting Series (2): Bubble, Selection, Insertion - Three O(n^2) Baselines

Systematic ACERS explanation of bubble/selection/insertion sorts: principles, stability, scenarios, and multilingual implementations with selection guidance.

December 2, 2025 · 7 min · map[name:Jeanphilo]

Sorting Series (1): How to Choose an Algorithm - Time, Space, Stability, Scenarios

Use the ACERS template to map common sorting algorithms by scenario, complexity, stability, and engineering usage, with runnable examples and a selection checklist.

December 1, 2025 · 6 min · map[name:Jeanphilo]

UFW + CrowdSec: Stop Malicious Port Scans (From Fail2ban Pain to a Modern Solution)

UFW + CrowdSec: Stop Malicious Port Scans Subtitle / Abstract: How do you protect exposed server ports? This guide shows how to move past Fail2ban regex hell and build a stable, automated, intelligent port-scan defense system. Target readers Developers using FRP or reverse tunnels Operators of cloud servers (Tencent, Alibaba, AWS, etc.) Linux users who want to stop port scans and SSH brute force People using Fail2ban who want a modern alternative Anyone improving personal server security Background / Motivation: Why you need port-scan defense When you run FRP (frps + frpc) or expose multiple ports, you will often see: ...

November 22, 2025 · 3 min · map[name:Jeanphilo]

WireGuard Full Guide: Build a Secure High-Speed Private Network (VPN Tutorial)

WireGuard Full Guide: Build a Secure High-Speed Private Network (VPN Tutorial) Subtitle / Abstract: A beginner-to-intermediate WireGuard VPN guide. Learn to build a fast, secure private network and enforce a zero-exposure model where services are only reachable through VPN. Target readers People who want to hide server or PC ports behind a VPN Users who want to reduce scanning and brute force risk Anyone building a private LAN or remote access to home Linux/Windows users, developers, and ops beginners Background and motivation: Why WireGuard? If you expose ports to the public internet (SSH, databases, admin panels), you will face: ...

November 20, 2025 · 4 min · map[name:Jeanphilo]

How to Build a Blog System

Build a Hugo Blog with GitHub Pages in 10 Minutes Subtitle / Abstract This guide takes you from zero to a deployed Hugo blog on GitHub Pages with GitHub Actions. It is beginner-friendly and explains the key moving parts. Target readers Hugo beginners Developers who want a quick technical blog Users of GitHub Pages and GitHub Actions Anyone who wants free static hosting Background / Motivation Common pain points when publishing a blog: ...

November 14, 2025 · 2 min · map[name:Jeanphilo]

How to Publish with Hugo

How to Publish with Hugo: From Markdown to Online Blog Subtitle / Abstract This guide explains how to create, manage, and publish Hugo posts: front matter, drafts, images, directory structure, local preview, and deployment. Target readers Hugo beginners Developers building a technical blog with Hugo Writers using Markdown + static sites Users of PaperMod, DoIt, and similar themes Background / Motivation After setting up a Hugo site, common questions include: ...

November 14, 2025 · 2 min · map[name:Jeanphilo]

Write Clear Issues with Templates: From Zero to GitHub Issue Forms

Title (accurate and keyword-rich) Write Clear Requirements with Issue Templates: A Complete Guide to GitHub Issue Forms Subtitle / Abstract This post teaches you how to configure GitHub Issue templates for feature requests and bug reports, including folder structure, YAML forms, Markdown templates, and common pitfalls. It is ideal for teams that want clearer requirements and less back-and-forth. Target readers This article is for: Backend/frontend/full-stack engineers who create Issues regularly Leads/TLs/architects who want standardized requirement intake Mid-level developers familiar with GitHub but new to Issue templates Beginners can follow, but basic GitHub knowledge is assumed. ...

November 11, 2025 · 7 min · map[name:Jeanphilo]