摘要: ou are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue repr 阅读全文
posted @ 2026-07-23 00:22 北叶青藤 阅读(2) 评论(0) 推荐(0)
摘要: def root_to_target(root: TreeNode, target: int): path = [] def dfs(node): if not node: return False path.append(node.val) if node.val == target: retur 阅读全文
posted @ 2026-07-23 00:16 北叶青藤 阅读(2) 评论(0) 推荐(0)
摘要: A good way to think about Dijkstra is: Dijkstra works when the first time you remove a node from the priority queue, you already know its optimal valu 阅读全文
posted @ 2026-07-21 00:49 北叶青藤 阅读(3) 评论(0) 推荐(0)
摘要: Implement a thread-safe bounded blocking queue that has the following methods: BoundedBlockingQueue(int capacity) The constructor initializes the queu 阅读全文
posted @ 2026-07-16 12:50 北叶青藤 阅读(3) 评论(0) 推荐(0)
摘要: Suppose you are given the following code: class FooBar { public void foo() { for (int i = 0; i < n; i++) { print("foo"); } } public void bar() { for ( 阅读全文
posted @ 2026-07-16 07:05 北叶青藤 阅读(8) 评论(0) 推荐(0)
摘要: Suppose we have a class: public class Foo { public void first() { print("first"); } public void second() { print("second"); } public void third() { pr 阅读全文
posted @ 2026-07-16 05:43 北叶青藤 阅读(4) 评论(0) 推荐(0)
摘要: Given a URL startUrl and an interface HtmlParser, implement a Multi-threaded web crawler to crawl all links that are under the same hostname as startU 阅读全文
posted @ 2026-07-16 05:02 北叶青藤 阅读(6) 评论(0) 推荐(0)
摘要: import queue import threading import time # Create a queue q = queue.Queue() def worker(): while True: # Retrieve a task from the queue item = q.get() 阅读全文
posted @ 2026-07-13 04:33 北叶青藤 阅读(5) 评论(0) 推荐(0)
摘要: part 1. 给 时间 和 IP, 看在提供的input里面如果ip 超出了一个threshold,判断为机器人,output 机器人的ip input: following string, and threshold 1, ip11, ip21, ip14, ip14, ip25, ip3 is 阅读全文
posted @ 2026-04-06 12:01 北叶青藤 阅读(13) 评论(0) 推荐(0)
摘要: Problem: Storefront Log Rate Limiter You are given a stream of log events. Each event contains at least: timestamp: arrival time (assume integer secon 阅读全文
posted @ 2026-04-06 11:07 北叶青藤 阅读(10) 评论(0) 推荐(0)