今日已更新 222 条资讯 | 累计 40667 条内容
关于我们

标签:#coding

找到 185 篇相关文章

AI 资讯

LeetCode 3116 (Hard) — binary search + inclusion-exclusion makes it easy

Full walkthrough: https://www.youtube.com/watch?v=vFuFA3ByCs0 LeetCode 3116 — Kth Smallest Amount With Single Denomination Combination. Here’s the trick everyone misses: Brute force (generate all multiples, pick k-th) fails because k can reach 2×10⁹. The real approach: Binary search the answer X Count valid amounts ≤ X using inclusion-exclusion Odd subsets add, even subtract (bitmask over coins) LCM via GCD, break when LCM > X O(n · 2ⁿ · log(k·M)) — passes cleanly. The 26% acceptance rate makes this look harder than it is. Once you see the count(X) monotonic trick, it clicks.

2026-08-21 原文 →
AI 资讯

I Let an AI Agent Run a SaaS Like a Solo Founder. It Made the Same Mistakes Humans Make.

I expected the audit to find broken code. That's what I was bracing for going in — a pile of half-working features, sloppy logic, the kind of mess you'd assume from software built at maximum speed with no human reviewing every line. That's not what I found. Almost everything Claude built actually worked, taken piece by piece. What I found instead was something I didn't expect at all: the agent had made the exact same mistakes I've watched human startup teams make, over and over, when they move fast and nobody's job is to say no. That's the real story here, and it's more interesting than "AI wrote bad code" would have been. The experiment The project is called GetPricePulse — a SaaS pricing intelligence product. It's Claude's entry from The $100 AI Startup Race , the season-long challenge I run where seven AI agents each get $100 and full autonomy to build a real startup from scratch, with no human coding and no product manager in the loop. Each agent picked its own idea and ran with it. Claude picked SaaS pricing intelligence, named it PricePulse, and kept building on it for the entire race. That "no product manager in the loop" part is the thing that made this interesting to watch. Nobody was deciding what PricePulse should be. Nobody was saying "we have enough pricing tiers now" or "this feature doesn't belong here." Claude got to build exactly what its own priorities told it to build, at whatever speed it chose, for the length of the race — optimizing, as far as I could tell from the commit history, for speed, feature creation, shipping, and monetization experiments. Not correctness. Not coherence. Not "does this still make sense in three weeks." I've written before about what all seven agents in this race said, independently, when I asked them what AI agents still can't do — they converged on the same answer without seeing each other's responses. This piece is narrower: a full production audit of Claude's specific build, PricePulse, done after the race, before I

2026-08-21 原文 →
AI 资讯

Why 75% of Developers Prefer Claude Code Over Codex

Photo by Microsoft Copilot on Unsplash TL;DR: In a poll of 138 developers, three‑quarters say Claude Code outperforms Codex for everyday AI‑driven coding, pointing to higher accuracy, deeper context awareness, and a smoother workflow. The AI‑coding battlefield has been dominated by OpenAI’s Codex for years, powering tools like GitHub Copilot and shaping how developers write code. Yet a fresh wave of feedback suggests a shift: Anthropic’s Claude Code is rapidly becoming the preferred assistant for many programmers. A recent survey of 138 software engineers—spanning startups, enterprise teams, and freelance coders—revealed that 75% now rely on Claude Code as their go‑to AI partner. What drives this migration, and what does it mean for the future of AI‑augmented development? Survey Overview and Key Findings The questionnaire targeted developers who regularly use AI code generators, asking them to rank their primary tool and rate specific workflow attributes. Respondents represented a broad skill spectrum, from junior developers to senior architects, and worked across languages such as Python, JavaScript, Java, and Go. Adoption rate: 104 out of 138 participants (75%) listed Claude Code as their primary AI assistant, while only 34 (25%) still favored Codex. Primary criteria: Accuracy of generated snippets, ability to retain long‑form context, and ease of integration into existing IDEs topped the list. Secondary factors: Cost efficiency, response latency, and the perceived safety of the model (fewer hallucinations) also swayed decisions. The data paints a clear picture: developers are no longer satisfied with a one‑size‑fits‑all approach. They want an AI that can understand the nuance of a multi‑file project, stay on‑topic across extended sessions, and deliver code that compiles on the first try. Why Claude Code Wins Over Codex Higher Accuracy and Fewer Hallucinations Respondents repeatedly highlighted Claude Code’s ability to generate syntactically correct, production‑re

2026-08-21 原文 →
AI 资讯

The Open-Sourcing of DeepSeek Harness Opens the Door to Modular, Unbundled AI Agent Infrastructure

DeepSeek has released a developer preview of DeepSeek Harness (dsh), an open-source execution runtime for building autonomous AI agents. The software features a micro-kernel architecture with modular plugins for various functional units. The release includes an append-only event logging system for tracking execution activities. Adoption may depend on plugin ecosystem stability and API maintenance. By Olimpiu Pop

2026-08-20 原文 →
AI 资讯

Foodwars: Battle of the Comfort Foods

What if deciding what to eat felt as exciting as winning a championship? It's 2 AM. You're hungry. You open your favorite food delivery app, convinced you'll order something in two minutes. Thirty minutes later, you're still scrolling. Pizza? Burger? Pasta? Fries? Momos? Ice cream? Suddenly, every option looks equally good, and now you're questioning your entire existence just because you wanted dinner. I have this problem almost every time I order food. So when I saw the DEV Challenge, I wanted to build something fun around this tiny but painfully relatable problem. Unfortunately, I couldn't finish it before the deadline, but I still wanted to share the idea because it's one of those projects that made me smile while building it. Meet Foodwars . Instead of endlessly scrolling through hundreds of dishes, why not let your favorite comfort foods battle each other until only one champion remains? What I Built We've all watched cooking shows like MasterChef and somehow turned into professional judges sitting comfortably on our sofas. "That steak is overcooked." "The sauce needed more balance." "I would've plated it differently." As if Gordon Ramsay personally asked for our opinion. Foodwars lets us finally put those imaginary judging skills to good use. Instead of comparing hundreds of dishes at once, the platform randomly pairs comfort foods against each other in head-to-head battles. You become the judge. Pick the winner, move on to the next matchup, and continue until one food survives the tournament. No endless scrolling. No decision fatigue. Just a series of fun, quick decisions that eventually crown your Ultimate Comfort Food . And once the champion is decided... Go order it. Or cook it. Either way, dinner has finally been decided. Demo comfort-foodwars.vercel.app Features of Foodwars Foodwars isn't just a random food picker. Every round is designed to make choosing food feel like a game instead of a chore. 1. Interactive Tournament Brackets Instead of presenting

2026-08-20 原文 →
AI 资讯

Three Lines to Draw Before You Scrape Instagram

Most write-ups on this subject are about technique. This one is about the three decisions you should make before you write any code, because in my experience every project that went badly went badly for a reason that was decided on day one and not noticed until much later. I have built this kind of collection twice, for competitive analysis and for a partner-vetting workflow. Neither of them needed to touch anything behind a login, and I want to explain why that turned out to be the useful constraint rather than the limiting one. Line one: the login wall is a boundary A login wall is a statement about who the content is for. Treating it as an engineering obstacle to be routed around is the decision that puts a project on the wrong side of everything: terms of service, the platform's own detection, and in several jurisdictions the law. So the first line is simply: if it requires an account to see, it is out of scope. Not "hard," not "for later." Out of scope. I am not going to discuss techniques for getting past one, and I would be sceptical of any article that does. The interesting engineering question here is not how to see more. It is how much you can actually do with what is openly published, and the honest answer is: considerably more than people assume before they check. This constraint also has a practical benefit that is easy to miss. A pipeline built only on openly available data does not break when authentication changes, does not require credential management, and does not put an account at risk. Mine has survived two platform changes that took down colleagues' authenticated collectors. Line two: public does not mean unrestricted The second line is the one developers get wrong most often, and it has nothing to do with access. Data being publicly visible says nothing about whether you may store it, for how long, or what you may do with it. In the EU and UK, information about an identifiable person is personal data whether or not they published it themselves

2026-08-19 原文 →
AI 资讯

Your AI-Generated Code Might Not Be Yours

If you use GitHub Copilot, Claude, Cursor or any other AI coding assistant to write production code, the legal ownership of what you ship is less settled than your licence agreement implies. The US Copyright Office ruled in January 2025 that purely AI-generated material is not copyrightable, and that prompts alone do not provide sufficient human control to earn protection. Code you wrote with heavy AI assistance sits in an uncertain middle ground: it may be copyrightable, it may not, and no court has drawn the line for software. The answer-first version: you probably do not own copyright in the portions of your code that an AI wrote without substantial human direction, and you may not be able to prove where the boundary lies. This does not mean someone else owns it — it may be uncopyrightable altogether, like a phone book. But your employment contract, your client agreement and your open-source licence all assume you hold full copyright in your deliverables. That assumption is now an open question. The rule, plainly stated Purely AI-generated output is not copyrightable in the United States. This is not a prediction or a legal opinion; it is the stated position of the US Copyright Office, set out in its January 2025 report Copyright and Artificial Intelligence, Part 2: Copyrightability . The report received over 10,000 public comments and represents the Office’s most comprehensive statement on the subject. Its conclusions are clear: “material generated wholly by AI is not copyrightable”, and existing law is adequate to handle the question without new legislation. The nuance sits in the middle ground — which is exactly where most AI-assisted coding lives. What the Copyright Office said The report draws several lines. First, it confirms the long-standing requirement that copyright requires a human author. An AI system cannot be an author, regardless of how sophisticated its output. Second, it addresses prompts: “based on the functioning of current generally available

2026-08-19 原文 →
AI 资讯

The Rust Awakens: Ownership Explained for JavaScript Devs

The Quest Begins (The "Why") Hey friend, picture this: you’re happily writing JavaScript, tossing objects around like confetti at a parade, and then you decide to give Rust a spin. You open the compiler, write a simple function that returns a slice of a vector, and boom— error[E0505]: cannot move out of … because it is borrowed . Your brain does a double‑take. “Wait, I didn’t even touch anything!” you mutter, staring at the screen like you just missed a plot twist in Inception . That moment was my dragon. I’d spent years trusting the garbage collector to clean up after me, and Rust’s ownership system felt like a strict sensei who wouldn’t let you leave the dojo until you bowed correctly. I was frustrated, curious, and honestly a little scared. But once I grasped the core ideas, the whole language started to click like a well‑oiled machine. So why does ownership matter? Because it gives you memory safety without a runtime garbage collector. No surprise pauses, no hidden allocations—just compile‑time guarantees that your program won’t dereference null or use‑after‑free. For a JS dev used to “it just works”, that’s a superpower worth earning. The Revelation (The Insight) The big surprise? Ownership isn’t just about who “owns” a value; it’s about how that value can be accessed, moved, or borrowed at any point in the program. Three rules govern everything: Each value has a single owner. When the owner goes out of scope, the value is dropped. You can either have one mutable reference or any number of immutable references to a value, but never both at the same time. Sounds simple, right? The gotcha is that Rust treats references as a separate kind of value with its own lifetime. If you try to store a reference beyond the lifetime of what it points to, the compiler says “nope”. This is where many JS devs stumble because in JavaScript a reference (or variable) just points to an object that lives as long as something else holds it—garbage collection decides when it’s gone. Le

2026-08-18 原文 →
AI 资讯

Modern IT Helpdesk & Ticketing System Built with PHP Native & MySQL

Are you looking for a clean, efficient, and modern way to manage IT support requests? Stop dealing with messy manual reports via chat and start using a professional ticketing system! In this video, I’m showcasing "HelpdeskKu"—a powerful, custom-built IT ticketing system designed for efficiency and ease of use. It’s built using pure PHP Native (making it fast and easy to customize) and styled with a sleek Dark Obsidian theme using Tailwind CSS. This app features three user roles (Admin, IT Support, and User) with an automated workflow, real-time analytics, and secure session management.

2026-08-16 原文 →
AI 资讯

An open-source, modular CMS for developers and AI-assisted/vibe-coded websites.

For years, the CMS ecosystem has largely followed the same formula. Install a CMS. Choose a theme. Install plugins. Customize some templates. Add an API when you need one. Then, eventually, try to connect everything to AI. But the way we build software has changed. Developers increasingly work alongside AI coding assistants. People are building websites by describing what they want instead of manually implementing every component. AI agents can now interact with external tools and services. APIs are becoming the foundation rather than an optional feature. Yet many traditional CMS architectures were designed for a world where a human administrator was the primary interface. That is the problem Basehim is trying to solve. Basehim is an open-source, modular, API-first PHP CMS built for developers, AI-assisted development, and the emerging world of AI agents. The goal isn't to replace every CMS. The goal is to provide a simpler foundation for people who want to build, customize, automate, and extend websites without being forced into a complicated infrastructure stack. The idea behind Basehim Basehim started with a fairly simple observation: The web is still full of ordinary PHP hosting. Millions of websites run on environments such as cPanel, Plesk, Apache, MySQL, and shared hosting. Yet many modern development tools increasingly assume that you have SSH access, Composer, Node.js, a build pipeline, background workers, containers, or a cloud deployment environment. Those tools are excellent when you need them. But they aren't always necessary for a CMS. Basehim takes a different approach. If your server can run modern PHP and MySQL or MariaDB, Basehim is designed to run there. You can upload the files, open the installer, configure the database, create the administrator account, and start building. There is no required Composer installation. There is no frontend build process. There is no daemon that has to remain running. There is no requirement for a public/ directory

2026-08-16 原文 →
AI 资讯

How Garbage Collection Works: Let's Build One From Scratch

Introduction Your program keeps creating objects. Every function call, every loop iteration, every parsed JSON response produces new ones. You don't manually delete most of them. You've never written a line of code that says "free this memory now." And yet your application doesn't immediately exhaust all available RAM and crash. So who cleans everything up? The answer is a garbage collector, a piece of the runtime that runs quietly in the background, deciding what your program no longer needs and reclaiming that memory for future use. Most developers interact with it only when something goes wrong: an unexpected pause, a memory leak, or an out-of-memory error that shouldn't be happening. Understanding how it actually works turns those confusing moments into solvable problems. And as a bonus, the core algorithm is simple enough to build yourself. We'll do that by the end of this article. -- 1. The Memory Problem Every time your program creates an object, the runtime allocates a chunk of memory to hold it. A string, a dictionary, a class instance: they all need memory, and that memory has to come from somewhere. The somewhere is a region called the heap , a pool of memory that the program draws from as it runs. When you create an object, the runtime finds a suitable slot in the heap and reserves it. When that object is no longer needed, that slot should be freed so it can be used for something else. In languages like C, you manage this manually. You allocate memory when you need it, and you free it when you're done. This gives you control, but it creates two classic failure modes. Free memory too early and you have a dangling pointer, a reference to memory that's now being used for something else. Forget to free it at all and you have a memory leak: the program slowly consumes more and more memory until it runs out. Automatic memory management exists to eliminate these failure modes. Instead of relying on the programmer to track every allocation and release, the runti

2026-08-15 原文 →
AI 资讯

Presentation: The Right 300 Tokens Beat 100k Noisy Ones: The Architecture of Context Engineering

Baruch Sadogursky and Patrick Debois discuss why coding agents fail due to bloated context windows and stuffed prompts. They explain practical context engineering fixes, including lazy-loaded skills, versioned context artifacts, externalized memory banks, and LLM-as-a-judge evals. Software architects & engineering leaders will learn how to turn raw markdown files into reliable agentic workflows. By Patrick Debois, Baruch Sadogursky

2026-08-14 原文 →
AI 资讯

Hello DEV! How I'm Blending Technical SEO with Vibe Coding to Build Tools

Hey DEV Community! 👋 I'm Hoang , a Technical SEO Specialist and Web Builder. I'm fascinated by the intersection of search engines, web technology, and AI. While I don't come from a formal Software Engineering background, I’ve been heavily leveraging AI-assisted development (Vibe Coding) to build custom web applications, utility tools, and micro-platforms. 🛠️ What I'm currently working on: SEO & Entity Optimization: Deep diving into Schema markup, web infrastructure, and Knowledge Graphs. Building Micro-Tools: Creating custom PHP scripts, automated quiz systems, and web utilities powered by modern AI LLMs. Server Management: Migrating and optimizing web apps directly on Nginx setups for maximum performance. 💡 Why I'm here: I joined DEV.to to share my journey as a non-traditional developer using AI tools to bring ideas to life fast, learn from experienced engineers, and discuss technical SEO best practices. Looking forward to connecting, sharing ideas, and learning with everyone here! Feel free to say hi or drop a line below! 🚀

2026-08-14 原文 →
AI 资讯

iris-agentic-dev -- Give Your AI a Live Connection to IRIS, Part 1: The Problem, the Tool, and Getting Started

Part 1 of a series. Part 2 covers the full tool catalog. Part 3 covers ObjectScript skills. Part 4 covers benchmarking and measuring what actually improves. The Problem Hiding in the Comments Thomas Mazur's post "Frogs, Chickens, AI, and VS Code" on VS Code productivity — Peacock, scoped workspace files, Copilot Agent mode — drew a sharper problem in the comments. Pietro Di Leo and Mike.W pointed out that when you work server-side in VS Code, the isfs:// workspace most production IRIS shops use, Copilot can only see the files open in your editor . It cannot index the virtual filesystem. On a mature IRIS application with thousands of classes, the AI works through a keyhole. John Murray pointed people at a project I've been building — iris-agentic-dev — and noted no Developer Community article existed for it yet. So here it is: why the problem exists, how the tool addresses it, and how to get it running in about five minutes. Why the AI Can't See Your Namespace When you open an isfs:// workspace, your IRIS classes live on the server, not on disk. The VS Code ObjectScript extension streams them to you on demand via the Atelier API — open a class, it fetches it; save it, it writes back. This works beautifully for editing. AI assistants such as Copilot work differently. They need a picture of the code around the file you're editing. Who calls this method? What inherits from this class? What other code touches this global? On a local project, the assistant can scan the files to answer those questions. An isfs:// workspace materializes files only when you open them, so there is nothing complete to scan. For a new project with a handful of classes, that may be tolerable. For a production IRIS system — ten thousand classes, Ensemble productions, custom %Library subclasses, business logic accumulated across years of development — the AI becomes nearly useless for the hard questions. It can help you write a new method if you paste in the surrounding context yourself. It cannot

2026-08-13 原文 →
AI 资讯

I built a tool that won't let you merge AI-written code until you can explain it

The problem AI agents like Claude Code and Codex write code fast. You run it, it works, you merge. A week later, there's a bug — and you realize you never actually understood the code you shipped. You just transcribed it. This is "vibe coding," and it's becoming the default way a lot of us write software now. What I built BuildIt is a set of hands-on courses where an AI agent proposes code changes like a normal diff — but you can't move to the next step until you explain, in an actual conversation with an AI tutor, why the change was made and what could go wrong. You also write the prompt yourself before the AI generates anything. No skipping. No checkbox you can fake. Real, compilable code from lesson one — not toy examples. 9 courses, 45 real shipped projects: Arduino STM32 (HAL) STM32 (LL) ESP32 Next.js Python React React Native Flutter How it works An AI agent proposes code (same diff screen you already know from Claude Code, Codex, Antigravity) BuildIt demands a line-by-line explanation before you can approve it An AI tutor verifies your understanding through real conversation Only then do you move to the next step Technical details The tutor AI runs entirely locally in your browser — your code never leaves your machine Credits-based pricing — unlock a course, it's yours even if you cancel later Built for teams too — share credits across an org, instill review habits from day one Why this matters AI will write more of our code over time, not less. That makes the ability to actually read and verify it more valuable, not less. BuildIt isn't trying to teach you to write code from scratch — it's trying to make sure you don't lose control of the code an AI writes for you. Would love feedback from anyone who's felt that "I merged this AI diff and don't actually understand it" moment. Try it here

2026-08-12 原文 →
AI 资讯

Monotonic Stack: The Matrix of Array Problems

The Quest Begins (The "Why") I still remember the first time I faced the “Next Greater Element” interview question. The array looked innocent enough, but every brute‑force attempt felt like I was hammering a nail with a sponge— O(n²) time, nested loops, and a sinking feeling that I was missing something elegant. I spent an hour sketching out the problem on a whiteboard, muttering, “There has to be a way to look ahead without looking back every single time.” That frustration is a rite of passage for many developers. We’re taught to think in terms of scanning left‑to‑right, but some array puzzles scream for a different perspective: we need to remember what we’ve seen in a way that lets us answer questions about the future elements instantly. Enter the monotonic stack—a deceptively simple data structure that turns those scary “look‑ahead” problems into straight‑line walks. The Revelation (The Insight) So what’s the secret sauce? A monotonic stack is just a stack that maintains its elements in strictly increasing or strictly decreasing order. Why does that help? Consider the Next Greater Element problem: for each index i , we want the first element to its right that’s larger than arr[i] . If we walk from left to right and keep a stack of indices whose next greater element we haven’t found yet, the stack will naturally be decreasing in value. Why decreasing? Imagine the stack holds indices [i₁, i₂, …, i_k] where arr[i₁] > arr[i₂] > … > arr[i_k] . When we encounter a new value arr[j] , any element on the stack that is smaller than arr[j] has just found its next greater element—namely arr[j] . We pop those indices, record the answer, and stop when we hit a value that’s not smaller (or the stack empties). Then we push j onto the stack. Because each index is pushed once and popped at most once , the total work is linear: O(n) . No nested loops, no repeated scans—just a single pass with a stack that does the heavy lifting. The same invariant works for other “first bigger/smal

2026-08-11 原文 →
AI 资讯

Budoucnost

AI jako partner, ne kalkulačka: člověk a AI při řešení Project Euler #185 srpna 2026 Co se stane, když člověk nepoužije umělou inteligenci pouze jako nástroj, který má dodat hotovou odpověď, ale jako partnera při řešení problému? Dnes jsme to vyzkoušeli na konkrétním problému z Project Euleru. Nechtěli jsme vytvořit nový algoritmus. Chtěli jsme zjistit, jak může vypadat skutečná spolupráce člověka a AI při hledání řešení. Experiment Vybrali jsme Project Euler #185 – Number Mind. Úloha obsahuje 22 šestnáctimístných sekvencí. U každé je uvedeno, kolik číslic je na správné pozici. Úkolem je najít unikátní šestnáctimístnou sekvenci, která splňuje všechna tato omezení. Na začátku jsme si stanovili jednoduché pravidlo: Nechceme pouze získat výsledek. Chceme společně hledat cestu k němu. První problém Naše první společná zkouška nedopadla podle očekávání. Ukázalo se, že jsme si pro experiment nezvolili ideální problém a postup. Místo toho, abychom se snažili chybu zakrýt, označili jsme první pokus jako neúspěšný a změnili postup. To se ukázalo jako důležitá součást experimentu. Chyba nebyla důvodem ukončit spolupráci. Byla informací pro další krok. Project Euler #185 U samotného problému jsme postupovali bez předem připraveného algoritmu. AI začala pracovat s kandidáty a jednotlivými řádky. Člověk průběžně sledoval strukturu problému a hledal jiný pohled. V určitém okamžiku přišel klíčový návrh: «„Nehledejme jen to, co je správně. Hledejme miny – čísla, která se nám nehodí.“» Tím se změnila orientace řešení. Místo hledání správných možností jsme začali systematicky vyřazovat možnosti, které nemohou být správné. Co přinesl člověk a co AI? Martin přinesl především: intuitivní pozorování, změnu perspektivy, rozhodování o směru dalšího řešení, pochybnosti a kontrolu jednotlivých kroků, myšlenku „min“. AI přinesla: rychlé zpracování velkého množství kombinací, strukturování hypotéz, systematické porovnávání, práci s omezeními, závěrečné ověření. Role se přitom během řešení nemě

2026-08-11 原文 →
AI 资讯

Union-Find: The Fellowship of the Sets

The Quest Begins (The "Why") I still remember the first time I saw LeetCode 323 “Number of Connected Components in an Undirected Graph”. I stared at the adjacency list, thought “I’ll just run a DFS from every node”, and coded it up in ten minutes. The solution passed the easy tests, but when the hidden test cases hit a graph with 10⁵ nodes and 10⁵ edges, my DFS started to choke—stack overflows, repeated visits, and a sinking feeling that I was brute‑forcing a problem that deserved a smarter tool. That night, after a few too many coffees, I stumbled upon a tiny comment in a discussion thread: “Union‑Find can do this in almost O(1) per operation”. My curiosity sparked like a power‑up in a retro arcade game. I had to know why this seemingly simple data structure could turn a nightmare into a breeze. The Revelation (The Insight) At its heart, Union‑Find (aka Disjoint Set Union, DSU) maintains a collection of elements partitioned into disjoint subsets. It supports two operations: Find(x) – returns the representative (root) of the set containing x . Union(x, y) – merges the sets containing x and y . The magic lies in two simple heuristics: Path Compression – when we walk up the tree to find a root, we make every node on that path point directly to the root. Future finds become flat, almost constant‑time. Union by Rank/Size – we always attach the smaller tree under the root of the larger one, keeping the overall tree shallow. Why does this give us near‑O(1) amortized time? Think of each Find as paying a small “tax” to flatten the path. The tax is paid only a few times per node before it becomes a direct child of the root. Over a sequence of m operations, the total work is bounded by O(m α(n)) , where α is the inverse Ackermann function—so slow‑growing it’s practically a constant for any realistic n . In plain English: every time we climb up, we leave a shortcut behind. The next climber benefits from that shortcut, and the structure keeps getting better. It’s like building

2026-08-11 原文 →