algorithms

Scientific Reports
DEV Community

Every time you tap "Book Ride," a system makes dozens of decisions in under two seconds: Which driver? What route? What's the real ETA? This article breaks down exactly how the dispatch algorithm works — from the greedy approach that fails at scale, to the bipartite graphs, batched matching, and surge pricing mechanics that power Uber, Lyft, Grab, and Gojek today. Why a Greedy Dispatch Algorithm …

algorithmscomputer-science
DEV Community

The Quest Begins (The "Why") Ever had one of those days where your API feels like it’s stuck in quicksand? I was building a simple rate‑limiter for a microservice that throttles requests per IP address. The idea was straightforward: every incoming hit checks a counter stored in Postgres, increments it, and if the counter exceeds the limit we return 429. At first it worked like a charm on my lapto…

algorithmscomputer-scienceprogramming-languages
DEV Community

Introduction: The Timeless Nature of Algorithms When you crack open a standard Data Structures and Algorithms textbook, it’s easy to assume the contents are products of the digital age. But here’s the kicker: many of these algorithms were devised centuries before computers existed . Take the Euclidean algorithm for finding the greatest common divisor—it dates back to 300 BCE . Or the sieve of Era…

algorithmscomputer-sciencemathematical-physics
DEV Community
Jaspreet singh
10h ago

Problem Statement Given a binary array nums , return the maximum number of consecutive 1's present in the array. Example Input: nums = [1,1,0,1,1,1] Output: 3 Explanation: The longest sequence of consecutive 1's is [1,1,1] Length = 3 Brute Force Intuition (Interview Explanation) For every index, if the element is 1 , start moving forward and count how many consecutive 1's exist. Keep updating the…

algorithmsmathematics
DEV Community

Problem Statement Given a sorted integer array nums , remove the duplicates in-place such that each unique element appears only once. Return the number of unique elements k . The first k elements of the array should contain the unique elements in their original order. Example Input: nums = [1,1,2] Output: 2 Modified Array: [1,2,_] Brute Force Intuition (Interview Explanation) One straightforward …

algorithmsmathematics
DEV Community

The Quest Begins (The “Why”) I still remember the first time I stared at a whiteboard interview question that asked for the shortest number of moves a knight needs to reach a target square on a chessboard. My brain went into panic mode: “Do I try every possible path? Do I keep a visited set? Do I… recurse?” I felt like Neo in The Matrix before he sees the code—everything was a blur of green symbo…

algorithmscomputer-sciencegraph-theory
DEV Community
Simon Green
14h ago

Weekly Challenge 377 Each week Mohammad S. Anwar sends out The Weekly Challenge , a chance for all of us to come up with solutions to two weekly tasks. My solutions are written in Python first, and then converted to Perl. Unless otherwise stated, Copilot (and other AI tools) have NOT been used to generate the solution. It's a great way for us all to practice some coding. Challenge , My solutions …

algorithmscomputer-scienceprogramming-languages
DEV Community

I Built a Consistent Hashing Ring in Pure Python and Finally Understood How Cassandra Distributes Data I've been using Cassandra and Redis Cluster for years. I knew consistent hashing was "how they work." But I never truly got it until I built one myself from scratch, in pure Python, with zero dependencies. This post is about what I learned doing that. The Problem Consistent Hashing Solves Imagin…

algorithmscomputer-science
DEV Community

Some API requests can't finish in time for a single HTTP response. Generating a report, transcoding a video, running a batch import — these take seconds or minutes, far longer than any client should hold a connection open for. If you try to do this work inside a normal request, you'll hit gateway timeouts, frustrated clients retrying half-finished jobs, and load balancers killing connections at 3…

algorithmscomputer-science
DEV Community

The Problem: Finding a Needle in a Haystack Answer-first: Uber and Grab find the nearest available driver in under 100ms by dividing the Earth's surface into hexagonal cells (H3 index at Resolution 8, each ~0.74 km²). Instead of calculating distance to every driver, they look up only the 7 cells nearest to the rider — reducing millions of comparisons to dozens. When you tap "Book" on Grab, the sy…

algorithmscomputer-science
DEV Community

Problem Description: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to the target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Link to the problem Solution: class Solution { public int [] twoSum ( int [] nums , int target ) { //map to store visited numbers along with the…

algorithmscomputer-science
Hacker News

In 1980, Intel released the Intel 8087 floating-point coprocessor, a chip that could make math up to 100 times faster. As well as arithmetic and square roots, the 8087 computed transcendental functions including tangent, exponentiation, and logarithms. But it all depended on a 69-bit adder: "The arithmetic heart of the floating-point execution unit is centered about a nanomachine comprised of the…

algorithmscomputer-science
DEV Community

Most conversational state management assumes the conversation is happening — a chat session, a websocket, a context window. Email breaks that assumption rudely: a customer replies five days after your agent's last message, and your code is expected to pick up exactly where things left off, with no session, no socket, and a process that has restarted twelve times since. The good news: email alread…

aialgorithmscomputer-sciencemachine-learning
DEV Community

A candidate finishes your take-home on a Friday afternoon. By the time a recruiter has cross-referenced three interviewers' calendars and emailed back a slot, it's Wednesday — and the candidate already has another offer in hand. Interview scheduling loses good people not because anyone is careless, but because the coordination loop is human-speed. Here's a pipeline that takes the human out of tha…

aialgorithmscomputer-sciencemachine-learning
DEV Community
Kehinde Giwa
1d ago

Hello all, I built a search engine from scratch in Java. In a previous course we were given it as a group project, but since I worked on just the document processing module, I didn't really understand (I didn't understand at all actually) how the rest of it worked, so I decided to rebuild it from scratch. I called it Nova Search. Keep in mind this post won't have a lot of code but I'll try to kee…

algorithmscomputer-scienceprogramming-languages
DEV Community

Over the years, I've seen many data platforms start with good intentions. A few scripts are created to move data from one system to another, and everything works fine. But as more vendors, APIs, and business requirements are added, those simple solutions gradually turn into hundreds of stored procedures, duplicated logic, and pipelines that become increasingly difficult to maintain. At some point…

algorithmscomputer-scienceprogramming-languages
DEV Community

The 24 Game is deceptively simple: given four numbers, combine them with + , - , × , ÷ to make exactly 24. Sounds easy, right? Try solving 1, 5, 5, 5 — it stumps most people. I built a complete solver for my math puzzle platform, and the algorithm turned out to be a great exercise in combinatorics, expression trees, and floating-point traps. Let me walk you through it. The Problem Space Four numb…

algorithmscomputer-science
DEV Community

After covering the foundational building blocks in Session 1, the next step is one of the most important problem-solving techniques in all of programming: recursion . And once recursion feels comfortable, it unlocks a powerful search strategy called backtracking . These two concepts appear everywhere in competitive programming — Fibonacci, binary search, tree traversal, merge sort, dynamic progra…

algorithmscomputer-science
Hacker News
Zhang; Luoyuan
2d ago

Computer Science > Artificial Intelligence Title:Can I Buy Your KV Cache? View PDF HTML (experimental)Abstract:Right now, across the world, AI agents are repeating the same absurd act: to read one document, they each recompute it from scratch. Every agent re-runs prefill, the most compute-intensive step a large model takes, over identical text, only to rebuild a key-value (KV) cache identical to …

aialgorithmscomputer-sciencemachine-learning
research.ioresearch.io

Sign up to keep scrolling

Create your feed subscriptions, save articles, keep scrolling.

Already have an account?