惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
宝玉的分享
宝玉的分享
P
Proofpoint News Feed
H
Help Net Security
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
C
Cisco Blogs
人人都是产品经理
人人都是产品经理
Know Your Adversary
Know Your Adversary
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Recorded Future
Recorded Future
I
Intezer
罗磊的独立博客
T
The Exploit Database - CXSecurity.com
Blog — PlanetScale
Blog — PlanetScale
Malwarebytes
Malwarebytes
Spread Privacy
Spread Privacy
T
Tor Project blog
V
Vulnerabilities – Threatpost
云风的 BLOG
云风的 BLOG
腾讯CDC
B
Blog RSS Feed
Stack Overflow Blog
Stack Overflow Blog
F
Future of Privacy Forum
MyScale Blog
MyScale Blog
Latest news
Latest news
IT之家
IT之家
MongoDB | Blog
MongoDB | Blog
The Hacker News
The Hacker News
S
Securelist
博客园 - 【当耐特】
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threat Research - Cisco Blogs
Jina AI
Jina AI
Cisco Talos Blog
Cisco Talos Blog
B
Blog
博客园 - 三生石上(FineUI控件)
Last Week in AI
Last Week in AI
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
V
V2EX
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Cloudflare Blog
The GitHub Blog
The GitHub Blog
博客园 - 聂微东
F
Full Disclosure
C
CERT Recently Published Vulnerability Notes

Hacker News: Show HN

Show HN: Write your BPF programs in Go, not C GitHub - Userfrom1995/benchd: BenchD is a browser-based CPU benchmark that runs fully on the client. Show HN: Proof Loop – I make my coding agents prove they finished the task Show HN: Free One-shot cloud agents with OpenCode and Daytona and Cloudflare Parseflow Show HN: Modernizing my old PhD work in an evening with little Qwen3.6 MoE Show HN: GitVitae – Free hosted portfolio and resume for anyone GitHub - wavever/buildby: Detect whether desktop apps are built with Electron, Flutter, Tauri, Qt, .NET, JVM, CEF, or native code. boku — YAML task runner Show HN: Darc – grep-like memory search tool for coding agents Mixpanel Headless - Mixpanel Docs Show HN: A demo video of Effected Keyboard 2 Introducing Open Public awesome-skills/gtm-mavericks at main · conductor-oss/awesome-skills Show HN: ATM, a tiny terminal task manager for local coding agents Freenet Workspace Show HN: AI Manager Show HN: SubTrack – Find forgotten subscriptions via bank transaction scanning Show HN: We dropped Go for Rust in our real-time telephony AI media plane Show HN: I Dedicated 4 Years to Mastering Offline Password Cracking Home — Noada Show HN: I Made a Claude Skill for SDD Show HN: Twixt – transform one word into another in four moves Show HN: Daily word puzzle game based on polysemy GoKubeDownscaler: Reduce Kubernetes Costs Off-Hours GitHub - openclaw-easy/ViralMint: Open-source viral content pipeline — scout trends, analyze competitors, generate AI videos, auto-publish. AGPL-3.0. GitHub - baidu-baige/LoongForge: A modular, scalable, high-performance training framework for LLMs, VLMs, diffusion, and embodied models. Show HN: (Better) Chrome Tab Manager Show HN: SoMatic – Vision-based OS automation framework for AI agents Physics AI – Free Physics Solver Online (Step-by-Step) SUPPLYCHAIN.FAIL — Open Source Vulnerability Timeline PocketWebTools GitHub - mirshko/boatswain: A macOS menu bar app for Fathom Analytics. Keep an eye on your site stats without ever leaving your keyboard. What does your investment actually buy? — Post-Money SAFE Calculator GitHub - vipulawl/claude-tips: Customize Claude Code spinner tips with live jokes, quotes, facts, or your own content GitHub - changespec/spec: ChangeSpec: open specification for software change communication Show HN: I built a private, manual 0% balance transfer tracker 3.125-Bit LLM quantization bypassing tensor cores Medical curiosities | Thomas Morris FlutterTime ~ Timezone Planner Steam 上的 Junebug GitHub - Helvesec/rmux: Universal Rust multiplexer with a typed SDK — drive any CLI or TUI app from code. Native on Linux, macOS, and Windows. GitHub - manas15/try-on: LiveLook — Real-time virtual try-on with gesture control, powered by Decart's Lucy VTON model GitHub - vitalysim/the-knowledge-guy: Turn any PDF or EPUB into a structured Claude Code skill - then ask your whole bookshelf a single question. Gemini Omni Flash AI Video Generator | Free Online GitHub - elliotgao2/handsets: A high-performance Android control CLI, built for agents and humans GitHub - enzoferraripapa-arch/ai-vprocess-ops: Engineering memory for AI coding agents: requirements, decisions, evidence, traceability, and V-process/ALM handoff Show HN: Dokkaebi – Run your WASM backend directly on the client side Send messages beyond your lifetime SkinMax App | Your Personal Skin Care Coach GitHub - kmdupr33/fks2g: A CLI for generating LLM-backed metrics for deciding how closely to review code ISS QuietGPT - Make ChatGPT Reply Smaller GitHub - Quintisimo/macfigure: Mac configuration in pkl. Simple alternative to nix-darwin Show HN: SafeRun – Replay debugging and inline prevention for AI agents 3 GitHub - sathvikc/agent-chat-bridge: Turn any AI agent chat session into an async agent. Register a timer, shell command, or webhook — the bridge automatically resumes the session with your prompt when the trigger fires. SnapAPI - Website Screenshot & Data Extraction API Introducing @cipherstash/stack Show HN: E2E Encrypted Terminal Screen Share Windows 98½ Show HN: SafeRun – Replay debugging and inline prevention for AI agents 2 Show HN: My custom Statusline for Claude Code (Python wrapper around claudeline) GitHub - kageroumado/phosphene: A video wallpaper engine for macOS Tahoe Best Remote Jobs — Work From Home | RemoteJobs.place udoc Free AI Rewriter - Revise GitHub - arashThr/hugo-flow: Simple rich-text CMS for Hugo weblogs. Try at https://hugo.arashtaher.com GitHub - light-cloud-com/ice: Free, open-source, visual studio for cloud infrastructure for macOS, Windows & Linux. GitHub - kouhxp/yapsnap: Snap any video URL or audio file into plaintext. No GPU. No cloud. One command. What if we made SIMA2 from Temu iPhone 版“Today” - App Store Runo - Web Scraping API | Any URL to Typed JSON Show HN: AI Editor for Websites GitHub - AdamGonda/ward: Run [ npm i ] safely, audit installs inside a docker container. The Crucible — 8 voices, one verdict Screenshot 2026 05 20 at 4 03 10 PM — Postimages Show HN: Chess Puzzles, but for Developers Show HN: I built Istanbul live transit map Show HN: Agent.email – sign up via curl, claim with a human OTP GitHub - mfairley/expo-callkit-telecom: 📞 CallKit + Core-Telecom for React Native + Expo. A modern react-native-callkeep alternative. I tried 4 LLM speedup techniques on CPU. Three made it slower. Show HN: I made a tool for learning scales, chords, and how to combine them Learn how to build AI products through practice 1 BTC = 17.17 troy oz of gold · Bitcoin Weigh-In p-Hacker — top trending Client Challenge hty GitHub - Artain-AI/ignite-ms: Fast self-hosted embedding engine for search, RAG, and reindexing workloads on NVIDIA GPUs. Built in Rust + TensorRT for teams that care about scale, cost, and control. GitHub - mupt-ai/dari-docs: optimize your documentation through fleets of agents GitHub - dcostenco/prism-coder: The Mind Palace for AI Agents - HIPAA-hardened Cognitive Architecture with on-device LLM (prism-coder:7b), Hebbian learning, ACT-R spreading activation, adversarial evaluation, persistent memory, multi-agent Hivemind and visual dashboard. Zero API keys required. Catio | The Architecture IDE for Modern Software Systems SysWP Radar — Veja TUDO que toca seu site homecrew — package manager for agent skills GitHub - platform-engineering-labs/formae: Infrastructure-as-Code Platform Built for the Future VibeKeys Max - Ready to Ship Show HN: We wrote forensic intelligence reports on 20 open-source codebases GitHub - bytedance/Lance: A 3B-active-parameter native unified multimodal model for image and video understanding, generation, and editing. GitHub - zero-intelligence/zero-protocol: ZERO.md — A universal protocol for personal AI context. Your AI knows your project. It doesn't know you. This file fixes that. Show HN: Chatroom with curl command (requires IPv6)
Segment Tree — Algorhythm
bytego · 2026-05-21 · via Hacker News: Show HN

01 /

The one-sentence essence

Build a balanced binary tree where each node holds the aggregate of a range — sum, min, max, gcd, whatever. Any range decomposes into O(log N) canonical pieces that already live as nodes, so every range query and every point update is O(log N) instead of O(N).

Problemrange sum + point updateInput[2,5,1,4,9,3,7,6]Query[1,5]Updatea[3] = 10

tree[0,7][0,3][4,7][0,1][2,3][4,5][6,7][0][1][2][3][4][5][6][7]array2051124394357667

Array of length 8. We'll build a binary tree where every node stores the sum of a contiguous range.

step

0

/

36

phase

build

live

0 / 

36

02 / The pattern signature

# node covers [l, r]; agg = sum (or min / max / gcd / …)def build(node, l, r):if l == r: tree[node] arr[l]; returnm (l + r) // 2build(2·node, l, m); build(2·node+1, m+1, r)tree[node] tree[2·node] + tree[2·node+1]# query [ql, qr] — sum the canonical pieces inside itdef query(node, l, r, ql, qr):if qr < l or r < ql: return 0if ql ≤ l and r ≤ qr: return tree[node]m (l + r) // 2return query(2·node, l, m, ql, qr) + query(2·node+1, m+1, r, ql, qr)

03 / When to recognize this pattern

"range sum / min / max / gcd with point updates"

The textbook trigger. The array changes (point update), and you keep asking for the aggregate over arbitrary ranges. Prefix sum is a no-update sibling; segment tree is its mutable cousin. If updates never happen, prefix sum is simpler and tighter.

"count smaller / count of range sum"

The classic "inversions" family (LC 315, 327, 493) — sort or coordinate-compress the relevant key, then sweep and maintain a frequency segment tree. Each new element contributes a range-count query on what came before.

"range update + range query"

The grown-up variant. Add lazy propagation: each node stores a pending update for its subtree that's applied only when the recursion descends through it. Same O(log N), now both operations are ranged.

"interval / event / coverage with mutation"

Coordinate-compress the unique x-positions into a small array, then the segment tree maintains the live status (count, max height, etc.) at each compressed position. Skyline, rectangle coverage, calendar booking — all collapse to this.

04 / Common pitfalls

i.

Forgetting the +1 in the right half.

The recursion is build(2·node, l, m) and

build(2·node+1, m+1, r) — the right child starts at m+1, not

m. Off-by-one here gives a tree that double-counts arr[m]

or silently loses it depending on which half you bias.

ii.

Reaching for prefix sum first, then needing updates.

Prefix sum is O(1) per query but O(N) per update. The moment the problem says "now change arr[i]", you have to rebuild — at which point a segment tree (or a Fenwick tree for sum specifically) wins. Recognize the mutation requirement up front.

iii.

Sizing the tree array wrong.

A safe allocation for the flat array is 4·N. The exact bound is

2·next_power_of_two(N), but allocating 4·N avoids the math and the rare case where 2N is one short. Forgetting this on a tight bound produces an out-of-range write that's painful to debug.

05 / Go practice — on LeetCode

Four problems, ordered by difficulty. No solutions here, by design.