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

推荐订阅源

T
Threat Research - Cisco Blogs
G
Google Developers Blog
人人都是产品经理
人人都是产品经理
有赞技术团队
有赞技术团队
U
Unit 42
D
DataBreaches.Net
A
Arctic Wolf
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
T
True Tiger Recordings
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Proofpoint News Feed
M
Microsoft Research Blog - Microsoft Research
T
ThreatConnect
Blog — PlanetScale
Blog — PlanetScale
Cisco Talos Blog
Cisco Talos Blog
Recorded Future
Recorded Future
量子位
T
Threatpost
Security Latest
Security Latest
E
Exploit-DB.com RSS Feed
云风的 BLOG
云风的 BLOG
F
Full Disclosure
H
Help Net Security
P
Palo Alto Networks Blog
T
The Blog of Author Tim Ferriss
C
Cybersecurity and Infrastructure Security Agency CISA
美团技术团队
L
LangChain Blog
Latest news
Latest news
小众软件
小众软件
S
SegmentFault 最新的问题
Martin Fowler
Martin Fowler
Hacker News - Newest:
Hacker News - Newest: "LLM"
Engineering at Meta
Engineering at Meta
Google Online Security Blog
Google Online Security Blog
The Cloudflare Blog
Scott Helme
Scott Helme
博客园 - Franky
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recent Announcements
Recent Announcements
Microsoft Azure Blog
Microsoft Azure Blog
Know Your Adversary
Know Your Adversary
A
About on SuperTechFans
G
GRAHAM CLULEY
C
Comments on: Blog
The Register - Security
The Register - Security

DEV Community

PostgreSQL 08003 오류 원인과 해결 방법 완벽 가이드 JDK 26 Pitfalls: Why CPU-Bound Tasks are Killing Your Virtual Threads Oracle ORA-00057 오류 원인과 해결 방법 완벽 가이드 When the Event Log Became a Liability: What Happened When We Treated Events Like Garbage 文章标题23 文章标题 🧠 NeuroDoc: From Broken Prototype to Production-Ready Async AI Documentation Engine 主流 Android 架构十年演化史——我们到底在解决什么问题? A Decade of Android Architecture Evolution: What Problem Are We Really Solving? I watched a machine do the impossible. Now I'm learning to build one. The Six Things That Broke During My kubeadm Setup on Hetzner — and How I Fixed Them How to Create ByteByteGo Like Animated Diagrams for Free Why I drop from Fedora to BRGV-OS MP3 - SQLi, XSS, and CSRF WriteUp Apache Kafka End of Life: Kafka Versions EOL Every 4 Months — Are You Behind? Ruby on Rails End of Life: Rails 6.1 EOL, Rails 7.0 EOL — What's Still Supported in 2026 CentOS is Dead: CentOS 7 EOL June 2024, CentOS 8 EOL Dec 2021 — Your Migration Options Veeam Backup & Replication End of Life: What EOL Backup Software Means for Your Compliance Posture Threat Detection in Kubernetes with Falco My test suite was green. My software was lying to me. Debugging Playwright CDP Sessions That Lose Cookies and Proxy Context How Developers Are Actually Using AI at Work in 2026: A Brutally Honest Analysis of 10,000+ PRs, Real Productivity Data, and What Nobody's Talking About Apache Tomcat End of Life: Tomcat 9 is EOL — Migration Guide to Tomcat 10/11 The Open Source Illusion: Why "Free" AI Models Are Getting Expensive 102. Multi-Agent Systems: When One Agent Is Not Enough Processing a 2GB CSV in Node Without Running Out of Memory Math.random() Is Not Random Enough. I Found It Building API Keys in a 44K-Star Repo. I tracked Claude Code and Codex pass-rates for 95 days — what "getting dumber" actually looks like How I Built an AI Agent That Earns $500/Month in Open Source Bounties — Full Architecture, Real Code, and Honest Numbers After 72 Hours Why Digital Agencies Are Moving Client Sites to Headless CMS in 2026 Why I Built a Scientific Calculator in Pure C for Terminal Environments Built ResumeTrust AI: A MERN + Gemini Tool to Catch Fake Resume Skills 🛡️💻 Yo Vibe Coders, Stop Building FE Slop and Use Telegram Groups Instead Building with Bun and Cosmic: The Fastest JavaScript Stack in 2026 10 Essential Developer Tools You Didn't Know You Needed (All Free, No Signup) Account Arrears Fine-Tuning Qwen2.5-0.5B to Write SRE Post-Mortem Summaries Observability Telemetry and Predictive AIOps Hermes Agent for Developers: The Open Source AI Agent That Learns & Remembers Demystifying the Trinity: Functor, Applicative, and Monad in PureScript Tracking Five Upstreams, Fuzzing the Parsers, and a Front Door: What Changed in llm-cli-gateway Building a Cover Flow for Missed Shifts Day 19 - Relational Database Service Automate Kubernetes Image Vulnerability Scanning AI at the Wheel: When Hacking Stops Needing a Human" published: false description: "Five threats from late May 2026 mark an inflection point. The Agent Is Easy. The Loop Is the Job. — A Developer's No-BS Guide to AI Engineering in 2026 How Tall Tales Got Designed (in Letters) How We Built a Node.js Scaffolding Engine with Over 1 Million Mathematically Verified Architecture States I Found an AI Agent That Actually Remembers Everything Event-Driven Architectures with Apache Kafka: Powering the Next Generation of Banking Transformation Through Agentic AI and Real-Time Analytics Abusing c_variadic in Rust 인텔이 애플 칩을 제조한다 — 미국 반도체 자립 전략이 만든 거래 Your AI agent has a master key to everything. Here's why that's a problem. OpenAI Codex vs Google Antigravity: Architecture, Workflow, and Key Differences SecAPI: Secure, AI-Driven API Key Management & Leak Prevention Tauri Sandbox Permissions — Why Your Command Silently Does Nothing SQL Pattern Series #1: The Presence Pattern You'll not be replaced by AI if ... Every tutorial tells you to add .env to .gitignore. That's not enough. The First Brick on the Walled Garden — Rethinking e-Food Delivery as an Open Protocol How I Built My First AI-Powered App Without Writing a Single Line of Code 클로드 AI 중국 암시장 유통 실태 — 모델 증류로 정가의 10%에 복제되다 You're Using Git Wrong — How Worktrees Will Change Your Workflow Forever I Tested Every Web Scraping Tool Against Lazada — Here's What Actually Works (May 2026) Your CI Pipeline Is Lying to You — 5 Signals You're Ignoring (And How to Fix Them) The Habit That Was The Bug How to use AI in your development workflow without losing your edge I built a RAG pipeline from scratch, and one wrong answer made me dive even deeper into AI Engineering Stop Building Projects That Exist Only to Impress Other Beginners built a stranger chat app from scratch — and what we learned Why Your MCP Integrations Break Silently — And How We Built DriftGuard to Close the Gap 09/20: Layer 4 – The Transport Layer: TCP, UDP & Reliable Delivery Harmonic Drive vs Planetary Reducer: A Practical Guide to Transmission Selection for Robot Joints A quebra de um ideal: o choque entre a filosofia open-source e a realidade do mercado Git Advanced: The Commands I Wish I Knew Earlier (2026) SQL for Developers: The Practical Guide (2026) Error Handling in Node.js: Beyond Try/Catch (2026) I built an MCP server that lets Claude read my study data — here's how من فكرة طلابية إلى نظام مراقبة ذكي – رحلة مستوصف Vamos participar do GitHub Challenge! Medical World Model Prototype: SteeraMed Explained — From Report Reading to Life Trajectory Reasoning I Built 4 Real Mobile Apps With No Coding Background — Here's the Exact Workflow Is Claude directly editing your translation JSON files? Idempotency Keys: The API Pattern That Prevents Duplicate Charges (and Worse) How to optimize application performance — a hands on tutorial Global Precision & Financial Calculations I Spent the Last Few Days Testing AI Agents and Got Scared — So I Built Sentinel v0.3.0 Building AI Workflows Is Easy. Making Them Reliable Is Systems Engineering I got tired of sending resumes into the void, so I built an AI resume tailoring tool I Didn't Want to Open Excel Just to Generate Sequential Numbers in VS Code I Built a Q&A Bot for My Docs and Almost Gave Up (Here's What Worked) The Real Moat Isn't Software How to Transfer Files Between iPhone and Android (No Apps, No Cables) Code review I Ran the Same NestJS Prompt on Claude and Gemini. One Got 6 Security Errors. Here's What Both Missed. From Messy Data to a Health Digital Twin: Building a Multimodal RAG Pipeline with Unstructured.io & LlamaIndex Hytales Veltrix Config Files Were Breaking Production Search and No One Admitted How Often GitHub Copilot vs Cursor vs Claude Code: An Honest 30-Day Comparison (2026) The Anatomy of a 30-Point Security Audit (And Why Every Domain Needs One) Claude API vs OpenAI API: Developer Comparison (2026) What's a 1% Email Deliverability Improvement Worth to Your Business?
Linkedlist leetcode
Naveensivam S · 2026-05-30 · via DEV Community

Naveensivam S

cloning the ll into another using deep copy

  • initially we use hashmap to implement it .
"""
# Definition for a Node.
class Node:
    def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None):
        self.val = int(x)
        self.next = next
        self.random = random
"""

class Solution:
    def copyRandomList(self, head: 'Optional[Node]') -> 'Optional[Node]':
        if not head:
            return None
        h = {} 
        curr = head
        while curr != None:
            h[curr] = Node(curr.val) 
            curr = curr.next
        curr = head

        while curr != None:
            copy = h[curr] # this is where we are copying inside the dictionary itself.
            copy.next = h.get(curr.next)
            copy.random = h.get(curr.random)
            curr = curr.next
        curr = head
        return h[curr]

Enter fullscreen mode Exit fullscreen mode

Time complexity :

O(n)

space complexity

O(n) # which is bad

optimization

  • we need to reduce space complexity alone.
"""
# Definition for a Node.
class Node:
    def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None):
        self.val = int(x)
        self.next = next
        self.random = random
"""

class Solution:
    def copyRandomList(self, head: 'Optional[Node]') -> 'Optional[Node]':
        # if not head:
        #     return None
        # h = {} 
        # curr = head
        # while curr != None:
        #     h[curr] = Node(curr.val) 
        #     curr = curr.next
        # curr = head

        # while curr != None:
        #     copy = h[curr]
        #     copy.next = h.get(curr.next)
        #     copy.random = h.get(curr.random)
        #     curr = curr.next
        # curr = head
        # return h[curr]

        # optimal solutions 
        if not head:
            return None

        curr = head
        while curr!= None:
            copy = Node(curr.val)
            copy.next = curr.next
            curr.next = copy 
            curr = curr.next.next
        # now the array will look like this " a-a'-b-b'-c-c'"

        curr = head
        while curr != None:
            if curr.random :
                curr.next.random = curr.random.next
            curr= curr.next.next
        # now it will point the random too since curr.next.random is for copied part and curr.random.next is for copied partof random.

        # now we need to separate 
        curr = head
        curr_head = curr.next
        while curr:
            copy = curr.next
            curr.next = copy.next
            if copy.next:
                copy.next = copy.next.next
            curr = curr.next
        return curr_head

Enter fullscreen mode Exit fullscreen mode

  • now it has O(1) space complexity

Interview Explanation:
Initially we plan using hashmap which will use lookup of O(1) but we need space complexity of O(1) , to overcome it , we are use the same array , by inserting the copied inside the real linked list. and at last splitting that into two linkedlist.