
Real Interview Questions for the Software Engineer at Check Point
NewInterview Q&A
Q&A-1Given an array of integers, how would you find two numbers that add up to a specific target?
Reported in Software Engineer interview at Check Point Software
The 90-second answer
First I'd pin down what's being asked: are the indices or the values returned, can the array contain duplicates or negatives, is it sorted, and what should come back when no pair exists? I'll assume I return the indices of the two elements, values can be any 32-bit integers, duplicates are allowed, the array is unsorted, and an element can't pair with itself. If no pair exists I return an empty result.
The brute-force check of every pair is O(n²) time and O(1) space. For a log or packet batch of a few million entries that is too slow, so I'd use one pass with a hash map from value to index. For each element x, I look up target - x. If it's already in the map I have my pair. If not, I store x and move on. That's O(n) time and O(n) space.
# Python 3.12
def two_sum(nums: list[int], target: int) -> tuple[int, int] | None:
seen: dict[int, int] = {} # value -> index of first occurrence
for i, x in enumerate(nums):
j = seen.get(target - x)
if j is not None:
return (j, i)
seen[x] = i
return NoneThe lookup happens before the insert, so an element never pairs with itself. For nums = [3, 3] and target = 6 the function returns (0, 1), which is correct. If I inserted first, the second 3 would find its own index and return (1, 1).
Trace with nums = [2, 7, 11, 15], target = 9:
| i | x | target - x | in seen? | seen after step |
|---|---|---|---|---|
| 0 | 2 | 7 | no | {2: 0} |
| 1 | 7 | 2 | yes, index 0 | returns (0, 1) |
Where it breaks
- Overflow. In C, Java or any fixed-width language,
target - xcan overflowint32whentargetis large andxis very negative. In Java I'd compute it as along, or check the range before subtracting. - Sorted input. If the array is already sorted and I must return values rather than indices, two pointers give O(1) extra space. Sorting an unsorted array first costs O(n log n) and I lose the original indices unless I sort (value, index) pairs.
- Memory on huge inputs. The map holds up to n entries. If the stream is too large to hold, I'd process it in chunks, or switch to a sorted external structure and accept the extra log factor.
- Multiple pairs. The function returns the first pair it finds, not all of them. If the interviewer wants every pair, I'd keep a multiset of counts and handle the
target == 2xcase separately so the same value isn't counted against itself.
I'd test the empty array, a single element, duplicates that sum to the target, negatives, and a target that needs the last two elements.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-2How would you design a system to handle high traffic for a web application?
Reported in Software Engineer interview at Check Point Software
The 60-second answer
Before drawing boxes I'd pin three numbers: peak requests per second, read-to-write ratio, and the p99 latency budget. Assume 20,000 rps at peak, 95% reads, p99 under 300 ms. Then the design is about keeping most requests away from the database and keeping the stateful parts small.
Layers, outside in:
- Edge: a CDN serves static assets and cacheable GETs, and absorbs volumetric DDoS before it reaches origin. Per-client rate limits live here, not in the app.
- Load balancer: L7, health checks, connection reuse to backends.
- Stateless app tier: autoscaled on CPU and in-flight requests, no session affinity, sessions in signed tokens or a shared store.
- Cache: Redis in front of hot reads, cache-aside, TTLs with jitter so keys do not expire together.
- Database: a primary for writes, read replicas for reads, and a queue for work the user does not wait on (email, search indexing, analytics).
Arithmetic (hypothetical figures)
Little's law gives concurrency = rate × latency = 20,000 × 0.05 s = 1,000 requests in flight at a 50 ms average. At 800 rps per pod that is 25 pods at peak; with 30% headroom, 33. The autoscaler has to add capacity within a minute of a spike, so a pre-warmed minimum matters more than the maximum.
Database: 19,000 reads/s at a 95% cache hit ratio sends 950 reads/s to replicas. 1,000 writes/s fits one primary that sustains about 1,500 writes/s. I would not shard on day one; I'd shard by tenant once sustained writes pass roughly 60% of that ceiling.
Where Check Point's world changes the design
Inspection sits in the request path. A WAF or threat-prevention engine on every request is often the first bottleneck, and it has to choose between failing closed (block) and failing open (pass uninspected). Decide per route: fail closed on login and payments, fail open on public catalogue pages, and alert on every fail-open event. Scale gateway inspection separately from the app tier, so a signature-update CPU spike does not take down checkout.
Trade-offs
Caching adds staleness and invalidation work. Autoscaling lags the traffic it is reacting to. Queues make writes eventually consistent, so the UI has to show pending state. Each of these is worth paying for only where the load justifies it.
Failure modes and how you'd detect them
- Cache stampede: a hot key expires and thousands of misses hit the database together. Detect it as a DB QPS jump while the hit ratio drops. Fix with request coalescing or stale-while-revalidate.
- Pool saturation: each pod allows 20 DB connections, and requests queue behind them. Detect it as p99 climbing while CPU stays flat.
- Retry storms: client retries on timeout multiply load at the worst moment. Cap retries, use jittered backoff, and make writes idempotent with keys.
Trace: product page request
| Step | Where | Time |
|---|---|---|
| 1 | Edge miss, forwarded to LB | 3 ms |
| 2 | App reads product:881 from Redis, hit | 1 ms |
| 3 | Response returned | 40 ms total |
On a cache miss the trace adds a replica read of about 4 ms plus any wait for a pool connection, which is where saturation shows up first.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-3How would you design a system to detect and block malicious traffic in real time?
Reported in Software Engineer interview at Check Point Software
The 90-second answer
I'd put detection inline on the data path, because blocking means the verdict has to land before the packet is forwarded. Out-of-band detection (mirror traffic, alert later) tells you about an attack but cannot stop the first packet. So the design is a per-packet pipeline with a fast path for the common case and a bounded slow path for expensive inspection.
First I'd pin down assumptions: aggregate throughput per gateway, average packet size, whether we must inspect encrypted payloads, and how much latency we can add. Hypothetical figures for this answer: 100 Gbps per gateway and 1500-byte average packets gives about 8.3 million packets per second. Spread over 16 cores that leaves roughly 2 µs per packet per core, which rules out heavy work on every packet.
The pipeline:
- Flow lookup. Hash the 5-tuple into a connection table. Flows with a cached verdict skip inspection entirely. Most bytes travel this path.
- Stateless filters on new flows. IP reputation and protocol policy, served from in-memory structures (LPM trie for prefixes, hash set for exact IPs), pushed by the control plane.
- Deep inspection on the first N bytes of a stream. Signature matching with a multi-pattern automaton (Aho-Corasick) or a regex engine such as Hyperscan, run on reassembled data within a per-flow budget.
- Reputation lookups for domains, URLs and file hashes. Hits come from a local cache. Misses go to a cloud service asynchronously, with a defined default verdict while the answer is pending.
The decision logic:
verdict_t inspect(pkt_t *p) {
flow_t *f = flow_lookup(&p->tuple); // O(1) hash lookup
if (!f) f = flow_create(&p->tuple);
if (f->state == FLOW_ALLOW) return ALLOW;
if (f->state == FLOW_DENY) return DROP;
if (ip_blocklist_hit(p->src))
return drop_and_cache(f);
if (f->bytes_inspected < INSPECT_BUDGET) {
f->bytes_inspected += p->len;
if (signature_scan(f, p).malicious)
return drop_and_cache(f);
} else {
f->state = FLOW_ALLOW; // budget spent: trust the flow
}
return ALLOW;
}The budget is a deliberate trade-off. An attack that starts after the budget is spent on a long-lived flow gets through. Mitigate with periodic re-inspection of sampled flows and by lowering the budget for high-risk ports.
Failure modes and how I'd detect them
| Failure | Detection | Response |
|---|---|---|
| Reputation data goes stale | age of last successful push | fall back to last good set, page on-call |
| SYN flood fills the connection table | table occupancy % | SYN cookies, shorter idle timeout for half-open flows |
| Scanner falls behind | queue depth, p99 inspection latency | shed low-risk classes to fail-open |
| Rule blocks a business app | block rate per app, support tickets | per-rule detect-only mode, scoped exceptions |
Fail-open versus fail-closed is a per-traffic-class decision that I'd state explicitly. Admin and critical services fail closed. General browsing fails open with alerting.
Rollout. Every new signature ships in detect-only mode for about a week. I measure hit rate and false-positive rate per rule, then promote. Every verdict is logged with its rule id, so an operator can explain any block.
When not to do this inline. Full TLS inspection costs substantial CPU for decryption. I'd first use SNI and certificate metadata, and send only selected flows to a dedicated decryption tier.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-4Describe a time when you had to work with a difficult team member.
Reported in Software Engineer interview at Check Point Software
The 90-second answer
I pick a case where the friction was about a technical decision, then show how I moved it from opinion to evidence. The example below is hypothetical, with figures I'd label as illustrative if I were giving it in an interview.
I was changing the fragment reassembly path in a packet-processing service. A senior engineer on the adjacent parser team reviewed my pull requests and rejected them three times. His comments were short ("unsafe", "not acceptable for this module") and gave no test or input to act on. The team was carrying a release deadline, and the thread was getting personal.
I stopped replying in the review and wrote down what I could actually check. The disagreement came down to one claim: my change removed a bounds check the parser relied on. Instead of defending the change, I tested that claim.
| Step | What I ran | Result (hypothetical) |
|---|---|---|
| 1 | Old branch, 10,000 fuzz inputs from the corpus | 0 crashes |
| 2 | My branch, same corpus | 37 out-of-bounds reads on fragments over 4 KB |
| 3 | Minimal reproducer, one 4,097-byte fragment | Reproduces in 1 call |
That reproducer changed the conversation. I sent it to him with the sanitizer output and said I had missed the check and would restore it before doing anything else. He answered within the hour with a suggestion for where the length invariant should live, which was better than mine.
Two things made the difference. First, I separated the disagreement about the code from the tone of the exchange and only responded to the first. Second, I asked him what he needed to see to approve the change, and then supplied exactly that. I did not ask him to trust my judgement.
The patch merged two days later, a week before the deadline, with his name on the review. We kept working together on the next two releases. I still do a sanitizer run before arguing a point in review.
What I'd say I learned
When a review is hostile, the fastest route is usually a failing input, not a longer comment. Ask the other person what would change their mind, and check whether they are right before you check whether they are polite.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-5Describe a time you had to work under pressure to meet a deadline.
Reported in Software Engineer interview at Check Point Software
The 2-minute answer
The situation I'd describe: two quarters ago I owned the policy-compile path for a gateway management release. Before I start, I'd confirm what's fixed. In this case the release cutoff was fixed at nine working days out, the release gate required p95 install time under 90 s on a 5,000-rule benchmark, and the feature could ship behind a flag if needed. Those three facts decided most of what I did next.
A caching change I had merged for an earlier optimisation had regressed installs. The illustrative numbers were 40 s per 1,000 rules before, and about 4 min at 5,000 rules after. I reproduced it on the benchmark first, then profiled. The cache key included a per-request timestamp, so every rule object was invalidated on every compile. The cache was doing nothing except adding a lookup on each object.
The fix was to key the cache on the object's version number instead of the timestamp. Before merging, I needed proof that compiled output hadn't changed. I wrote a differential test that compiled three days of recorded customer policies with the old and new code and compared the output. The first run failed on timestamp fields in the output, which were noise, so I normalised those and re-ran. Then the output matched byte for byte.
I considered two alternatives. Reverting the caching change was the safest option but threw away the gain it was meant to deliver. Shipping with caching disabled behind a flag was a fallback I kept ready, with the flag defaulting off. I kept the fix as the main path and the flag as insurance.
On day two I told the release manager the numbers and said the differential test would decide the call on day seven. Nobody had to ask me for updates after that.
Result, using the same illustrative figures: p95 at 5,000 rules dropped from 4 min 10 s to 71 s. We shipped on day eight with a day in hand, and the flag was never turned on.
What I'd change: I sat on the regression for a day before raising it. The benchmark failed the first time I ran it, and I should have escalated that same hour rather than after I had a fix. A deadline gets less pressured when you tell people about a problem while you still have options.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-6What are the key considerations when implementing a secure API gateway?
Reported in Software Engineer interview at Check Point Software
The 90-second answer
I'd start by fixing the trust boundary. The gateway is the only component that sees untrusted traffic, so it authenticates, rejects bad input and enforces limits there, and the services behind it can assume those checks happened. I'd still keep authorization for each resource in the service, because the gateway doesn't know which order belongs to which customer. Then I'd cover five things: TLS and identity at the edge, token validation done strictly, input and size limits, rate limiting keyed to the right identity, and logging that doesn't leak secrets.
Token validation. Verify the signature against a pinned key set from the issuer's JWKS endpoint, and check iss, aud and exp on every request. Reject alg: none and any algorithm not on an allowlist, which is the class of bug RFC 8725 (JWT Best Current Practices) calls out. Don't let a token's header choose the verification key. Cache JWKS with a refresh on unknown kid, not on every request.
for req in inbound:
claims = verify(req.bearer, keys=jwks.pinned(), algs=["RS256", "ES256"])
require(claims.aud == "orders-api" and claims.iss == ISSUER)
forward(req.strip("X-User-Id", "X-Internal-*"), claims.sub)Stripping inbound headers matters as much as validating tokens. If a client can send X-User-Id and the gateway passes it through, the upstream trusts a value nobody checked.
Transport. TLS 1.2 minimum, 1.3 preferred (RFC 8446), with HSTS at the edge. Use mTLS between the gateway and upstreams so a service reachable from inside the network still refuses unauthenticated callers.
| Control | Setting I'd start with | Failure it prevents |
|---|---|---|
| Max body size | 1 MB default, per-route override | memory exhaustion on parse |
| Upstream timeout | 2 s, not unbounded | threads pinned behind a slow backend |
| Rate limit key | token sub, then IP for anonymous | one tenant starving others |
| Request ID | generated at edge, propagated | untraceable incidents |
The numbers are hypothetical starting points. Tune them from p99 latency and payload distribution.
Rate limiting. Keying on IP alone fails behind NAT and is trivial to rotate past. Key on authenticated identity where you can, and use a shared counter (Redis or similar) if you run several gateway instances. A per-instance counter with four instances lets a client through at roughly four times the intended rate.
Failure modes I'd check for:
- Validation failing open when the JWKS fetch times out. The gateway should fail closed and serve from cache with a bounded staleness.
- Error responses leaking stack traces or upstream hostnames. Normalise errors at the edge.
- Logs capturing
Authorizationheaders or request bodies with card or PII fields. Redact at ingestion, not in each service. - Clock skew causing valid tokens to fail
exp. Allow a small leeway, 30 s is common, and say so.
Detection is mostly metrics: 401 and 403 rates per route, JWKS refresh errors, and the ratio of stripped headers. A sudden spike in 401s after a key rotation points at the rotation, not an attack.
What I wouldn't do is treat the gateway as the whole security model. It reduces exposure. Each service still needs its own object-level authorization, which is where most real API breaches happen (see OWASP API Security Top 10, 2023, BOLA as item one).
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-7Design a system that receives messages with a send time and, when the right time comes, forwards all messages that were scheduled for that time.
Reported in Message Ordering and Timed Dispatch
The 90-second answer
Persist every message before acknowledging the producer, index it by send time, and run dispatchers that claim due rows in batches and publish them to the broker. The table is the source of truth. The timer is only a poll loop, so a crashed worker loses nothing.
Assumptions I'd state first: about 10k messages/s at peak, send times up to 30 days out, forwarding is at-least-once, and consumers deduplicate on message_id.
CREATE TABLE scheduled_message (
message_id uuid PRIMARY KEY,
send_at timestamptz NOT NULL,
seq bigint GENERATED ALWAYS AS IDENTITY,
payload bytea NOT NULL,
state text NOT NULL DEFAULT 'pending'
);
CREATE INDEX ON scheduled_message (send_at, seq) WHERE state = 'pending';Each worker runs this every 100 ms:
BEGIN;
SELECT message_id, payload FROM scheduled_message
WHERE state = 'pending' AND send_at <= now()
ORDER BY send_at, seq
LIMIT 1000
FOR UPDATE SKIP LOCKED;
-- publish the batch, wait for broker acks
UPDATE scheduled_message SET state = 'dispatched' WHERE message_id = ANY($1);
COMMIT;Arithmetic: 1000 rows per poll at 10 polls/s is 10k messages/s per worker. Four workers give 40k/s, four times the assumed peak. SKIP LOCKED lets workers claim disjoint batches without blocking each other.
Why now() comes from the database. Comparing send_at against each dispatcher's local clock lets skew between hosts release messages early or late. One clock source keeps the ordering decision in one place. Dispatch lag is then bounded by the poll interval plus batch processing time.
Ordering. Within one batch, rows come out in (send_at, seq) order. Two workers can publish adjacent batches out of order, so global ordering is not guaranteed. If consumers need order per entity, partition by key and assign each partition to exactly one dispatcher. Ordering then holds within the partition only.
| Failure | Detection | Response |
|---|---|---|
| Worker publishes, then dies before COMMIT | duplicate deliveries on the broker | consumers dedupe on message_id |
| Broker unavailable | pending backlog grows | stop claiming, retry with exponential backoff and jitter |
| Burst of 1M messages at 00:00 | dispatch lag p99 rises | add workers, raise batch size, watch index scan cost |
| Dispatchers fall behind | now() - min(send_at) over pending rows above 5 s | page on-call |
Alternatives. An in-memory timer wheel is fast, but timers vanish on crash unless rebuilt from storage, so it still needs the table. A Redis sorted set keyed by send time can lose up to about 1 s of acknowledged writes under AOF everysec, which is too much for scheduled sends. Broker-side delay features cap out early: SQS DelaySeconds maxes at 900 s, so they cannot hold 30-day schedules.
When not to use this. If every send time falls within a few seconds of insertion, an in-memory timer wheel with a write-ahead log is simpler and cheaper. The table design earns its cost once schedules are long and durability matters.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-8Design a system to share resources between different servers.
Reported in Share Resources Between Servers
The 90-second answer
I'd first pin down what 'resource' means, because it changes the design. I'll assume a finite pool, such as NAT source ports or concurrent-session licences, shared by about 20 gateway servers. Requirements: no unit is handed to two servers at once, and a unit held by a dead or partitioned server comes back without manual work. Assume roughly 60k ports and 5k allocations per second at peak.
The shape is a lease-based allocator on a strongly consistent store (etcd or another Raft-backed store, which gives compare-and-set and TTL leases). A server claims a block of units with a CAS, gets a fencing token, and renews with a heartbeat. Ownership is never inferred from local memory alone. Servers allocate individual units from their leased block locally, so the store is hit once per block, not once per allocation.
Why not the alternatives:
| Approach | Strength | Failure |
|---|---|---|
| Static partition per server | no coordination | strands capacity when load is uneven |
| Gossip-based sharing | no single point | converges eventually, too late to prevent double hand-out |
| Per-allocation lock call | simple | one store round trip per allocation, p99 suffers at 5k/s |
| Leased blocks with fencing | local speed, bounded staleness | needs clock-skew margin and fencing downstream |
Trace (hypothetical figures, 10 s TTL, renewed every 3 s, 2 s skew margin)
- t=0: gw-3 CAS
pool/nat-A/block/17from absent toowner=gw-3, token=812, store TTL 10 s, store expiry t=10. Local deadline t=8. - t=4 s: gw-3 renews. Store TTL resets to 10 s, so store expiry moves to t=14. Local deadline moves to t=12.
- t=6 s: gw-3 is partitioned. The renewal due at t=7 fails, and so does every retry after it.
- t=12 s: gw-3's local deadline passes. It stops allocating from block 17 and returns its unused units to its local free list.
- t=14 s: store expires the lease.
- t=15 s: gw-5 claims block 17 with token 813.
- A paused writer is the harder case. Suppose gw-3 stalls in GC at t=11.9, passes its deadline check, then resumes at t=15 and sends a write with token 812. The downstream store has already seen 813, so it rejects the write. Without that fencing check the stale write would land on a unit gw-5 now owns.
The skew margin is the part candidates skip. If local deadline equals store expiry, a clock drift of a few hundred milliseconds lets two servers both believe they own the block. Local deadline must sit comfortably before store expiry, and the margin should be sized from measured clock drift, not guessed. Note that the local deadline is measured from the last successful renewal, not from the original claim, which is why it moved from t=8 to t=12 in the trace.
Failure modes and detection
- Store unavailable: existing blocks keep working until their local deadline, then allocation fails closed. Alert on lease-renew error rate, not on allocation errors, because renew errors show up first.
- Stale writer accepted downstream: the fencing check is the only thing that stops it. Count rejected tokens; a non-zero steady rate means a server is pausing longer than the lease allows.
- Fragmentation: blocks held but mostly idle. Track free units per pool and return blocks idle past a threshold.
- Thundering herd on release: many servers claim freed blocks at once. Add jittered backoff on claim retries.
I'd finish by saying what I would not build first: a general-purpose distributed lock service. The pool is the only thing with a hard correctness requirement, so the allocator should expose exactly that operation and nothing wider.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-9Walk me through the architecture of a complex software project you completed during your studies or previous employment. Why did you choose this design?
Reported in Design a Complex Project
The 90-second answer
I'll use a packet-inspection pipeline I built at my last job. It was a C++ service on Linux that took mirrored traffic, matched it against a policy set, and emitted decisions and logs. The brief was 40 Gb/s aggregate per box at under 50 µs added latency for the 99th percentile, so the design followed from that budget.
I split it into three planes. A capture stage pulls frames from a kernel ring and hashes each flow's 5-tuple to a worker. Each worker owns its flows, so per-flow state needs no locks. Workers evaluate a compiled rule table and push decisions into a per-worker SPSC queue that a single logging thread drains. The control plane is separate: it compiles policy text into an immutable table and publishes a new pointer atomically. Workers pick up the new table at their next batch boundary, so a reload never blocks the data path.
I chose this over a shared-state design with a mutex around the rule set because the lock showed up at the top of every profile I took, and it made reload pauses visible as latency spikes. Flow-affinity hashing costs some load balance on skewed traffic, and I accepted that after measuring it.
| Stage | Ownership | Synchronisation |
|---|---|---|
| capture | one thread per NIC queue | kernel ring, no locks |
| match | one worker per flow hash bucket | none on the hot path |
| policy | control plane | atomic pointer swap, RCU-style release |
| logging | one drainer | SPSC queue per worker |
Arithmetic I used to size it. Hypothetical but representative: 40 Gb/s at 500-byte average frames is about 10 million packets per second. Across 8 workers that is about 1.25 Mpps each, or roughly 800 ns per packet. The rule lookup had to stay under 300 ns, which forced the compiled table and ruled out walking a list of 4,000 rules per packet.
Failure modes I designed for. Logging falls behind during bursts, so the SPSC queue drops with a counter instead of blocking the worker. The team alerted on drop rate above 0.1% over 60 seconds, because a silent drop on a security box is worse than a loud one. A bad policy push could compile but mis-order rules, so every table was checked against a golden set of 2,000 flows before publication, and the previous table stayed live if the check failed. Old tables were freed only after every worker reported the new epoch, which prevented use-after-free during reload.
What I'd change. The logging drainer became the bottleneck above roughly 30 Gb/s. I would shard the log queues by worker and merge at the sink, rather than keep one drainer.
Why this design over the alternatives. A single-threaded pipeline was simpler but could not meet the throughput target on one core. A DPDK-based kernel bypass would have cut capture cost further, but it took the NIC away from the rest of the host and added an operational burden the team did not want. The plane split plus flow affinity gave the throughput we needed with the simplest correct concurrency model I could defend.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-10Design a system that gets a URL and returns whether it is secure.
Reported in Secure URL System Design
The 90-second answer
First I'd pin down what 'secure' means, because it changes the design. I'll assume the verdict is one of safe, malicious, phishing, or unknown, with a reason code and an expiry time. I'll assume roughly 50k lookups per second at peak, a p99 budget of 50 ms for the synchronous path, and that a verdict may be up to 15 minutes stale. Transport security (is the TLS certificate valid?) is a cheap local check, so I'd fold it in as one signal, not the whole answer.
The core idea is that the request path never does deep analysis. It answers from a verdict store, and anything unknown goes to an asynchronous pipeline. Synchronous sandboxing of a page takes seconds, so it can't sit on a 50 ms path.
Canonicalise before anything else. HTTP://Example.COM:80/a/../login?utm=x#frag and http://example.com/login?utm=x must hit the same verdict. Lowercase the scheme and host, drop default ports, resolve dot segments, strip the fragment, and convert IDN hosts to punycode. Hash the canonical string with SHA-256 for the key.
# Python 3.12
from urllib.parse import urlsplit, urlunsplit
import hashlib
def canonical_key(raw: str) -> str:
p = urlsplit(raw.strip())
host = p.hostname.encode('idna').decode('ascii').lower()
port = p.port if p.port not in (None, 80, 443) else None
netloc = f'{host}:{port}' if port else host
path = p.path or '/'
canon = urlunsplit((p.scheme.lower(), netloc, path, p.query, ''))
return hashlib.sha256(canon.encode()).hexdigest()Note that urlsplit does not resolve .. segments, so a production version needs an explicit normalisation step there too.
Request path. The API hits a Redis cluster keyed by the hash. A hit returns the stored verdict and its TTL. A miss goes through two cheap checks: a Bloom filter over the known-bad domain feed (about 40M entries at a 0.1% false positive rate is roughly 72 MB) and a host reputation lookup. If neither decides, return unknown with queued: true and enqueue the URL.
| Stage | Typical cost | Output |
|---|---|---|
| Redis hit (about 95% of traffic, hypothetical) | 1 to 2 ms | stored verdict |
| Bloom plus host reputation | 3 to 5 ms | verdict or fall through |
| Async sandbox and classifier | 2 to 20 s | verdict written back to Redis |
With a 95% hit rate and a 1 ms cache, the blended cost stays well inside budget. The 5% of misses that fall through are the ones that matter, and they're why the async path exists.
Async pipeline. Workers fetch the URL in an isolated sandbox, follow redirects up to a limit, record the final URL, the DOM features, and the TLS chain, then run a classifier. Results are written back with a TTL: 24 hours for safe, 15 minutes for unknown so it gets re-checked soon, and longer for confirmed malicious.
Failure modes I'd watch for.
- Cloaking: the page serves benign content to the crawler's user agent and something else to real users. Rotate fingerprints and crawl from residential-like egress.
- Redirect chains that end on a different host than the one submitted. Score the final host, not only the first.
- Shared hosting: one bad tenant makes a whole IP or domain look malicious. Keep verdicts per URL, with the domain as a weaker signal.
- Stale
safeverdicts after a page is compromised. This is detected by re-crawl sampling and by user reports, and it's whysafehas a finite TTL. - Homograph domains that pass canonicalisation. Flag mixed-script labels as a feature rather than normalising them away.
- Cache stampede when a popular new URL misses everywhere at once. Use single-flight so one crawl serves all waiters.
Detection is by metrics I'd alert on: hit rate per verdict class, p99 latency per stage, and the rate of unknown responses. A sudden rise in unknown usually means the crawler or queue is degraded, and a silent fallback to safe on timeout would be the worst possible failure, so the timeout path must return unknown, never safe.
I'd choose this over a purely synchronous design because it bounds latency at the cost of freshness on first sight, and I'd state that trade-off explicitly to the interviewer.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-11Design a data structure that implements an LRU (Least Recently Used) cache.
Reported in Check Point Software Technologies Interview Questions
The 60-second answer
First I'd confirm the constraints: are keys and values opaque, is capacity fixed at construction, and is the cache shared across threads? I'll assume fixed capacity, opaque keys, and that get and put must both be O(1) on a hot path.
The structure is a hash map from key to node, plus a doubly linked list ordered from most recently used at the head to least recently used at the tail. The map gives O(1) lookup. The list gives O(1) unlink and relink of any node, which makes move-to-front cheap. Sentinel head and tail nodes remove the edge cases on insert and delete.
class LRUCache:
class _Node:
__slots__ = ('key', 'value', 'prev', 'next')
def __init__(self, key=None, value=None):
self.key = key
self.value = value
self.prev = None
self.next = None
def __init__(self, capacity: int):
if capacity <= 0:
raise ValueError('capacity must be positive')
self.capacity = capacity
self.map = {}
self.head = self._Node()
self.tail = self._Node()
self.head.next = self.tail
self.tail.prev = self.head
def _unlink(self, node):
node.prev.next = node.next
node.next.prev = node.prev
def _push_front(self, node):
node.next = self.head.next
node.prev = self.head
self.head.next.prev = node
self.head.next = node
def get(self, key):
node = self.map.get(key)
if node is None:
return self._MISS
self._unlink(node)
self._push_front(node)
return node.value
def put(self, key, value):
node = self.map.get(key)
if node is not None:
node.value = value
self._unlink(node)
self._push_front(node)
return
if len(self.map) == self.capacity:
lru = self.tail.prev
self._unlink(lru)
del self.map[lru.key]
node = self._Node(key, value)
self.map[key] = node
self._push_front(node)
_MISS = object()I return a sentinel _MISS rather than None, because None is a legal stored value and would make a miss indistinguishable from a hit.
Trace, capacity 2
| Step | Operation | List (MRU to LRU) | Result |
|---|---|---|---|
| 1 | put(1, a) | 1 | |
| 2 | put(2, b) | 2, 1 | |
| 3 | get(1) | 1, 2 | a |
| 4 | put(3, c) | 3, 1 (2 evicted) | |
| 5 | get(2) | 3, 1 | miss |
Step 4 is the one to check: the eviction takes the tail, not the most recently inserted node.
Alternatives and when not to use LRU
In Python, collections.OrderedDict gives the same behaviour with move_to_end and popitem(last=False), which is shorter and what I'd ship. In C or C++ the equivalent is std::list plus a map holding list iterators. In a kernel or packet-path component I'd use a fixed node pool allocated up front, so the fast path never calls malloc. Clock (second chance) approximates LRU with one reference bit per slot and avoids moving nodes on every hit, which matters under contention. LRU also thrashes on scans: one sequential pass over a large table evicts the whole working set. There, 2Q or ARC is the better answer, and I'd say so.
Concurrency
A hit reorders the list, so get is a write. A read-write lock buys nothing. A single mutex is correct but becomes the bottleneck on a multi-core data path. I'd shard by key hash into N independent LRUs with capacity divided across them. The cost is that eviction becomes per shard, so a skewed key distribution can lower the hit rate. I'd measure that before choosing N.
Failure modes
Forgetting to move a node on hit silently turns the cache into FIFO; a unit test with the trace above catches it. Deleting from the map before unlinking leaves a dangling list node. Capacity is only enforced on the insert path, so an update path that forgets the check grows without bound. In production I'd watch hit ratio and eviction rate per shard: a hit ratio that drops while traffic stays flat usually means the working set has outgrown capacity or the access pattern changed.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-12Walk me through how you would use Floyd’s two-pointer algorithm to determine whether a singly linked list contains a cycle.
Reported in Check Point Software Technologies Interview Questions
The 90-second answer
I'd use two pointers that start at the head. slow moves one node per step and fast moves two. If the list ends, fast or fast.next becomes null and there is no cycle. If the list loops, fast enters the cycle first, and the gap between the pointers shrinks by one each step, so they must meet. Time is O(n), space is O(1), and nothing is allocated, which matters on a packet path or in kernel code where allocation is restricted.
# Python 3.12
def has_cycle(head):
slow = fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow is fast:
return True
return FalseThe null check has to come before fast.next.next. Checking only fast crashes on a list with an even number of nodes.
Trace. Take A→B→C→D→B, so the cycle is B→C→D→B with length 3.
| step | slow | fast | note |
|---|---|---|---|
| 0 | A | A | start |
| 1 | B | C | |
| 2 | C | B | fast wrapped into the cycle |
| 3 | D | D | meet, return True |
Within the cycle the gap closes by one per step, so they meet within L steps of both entering it. Here that happens at step 3.
Finding the entry node. Interviewers often follow up with this. Let a be the distance from head to the cycle entry, and let the meeting point sit b steps past the entry. The cycle has length L. When they meet, slow has moved a + b and fast has moved 2(a + b), so a + b = kL for some k ≥ 1, which gives a = kL − b. Reset one pointer to head, advance both by one per step, and they meet at the entry after exactly a steps.
Trade-offs. Brent's algorithm keeps one saved pointer and teleports it to the current node at power-of-two steps. It dereferences fewer next pointers, which can help when each hop is a cache miss. Hash-set tracking is simpler but costs O(n) memory, and I would not use it on a bounded path.
Failure modes I would check for.
- Concurrent mutation. If another thread splices nodes while the walk runs, a false negative or an infinite loop is possible. The list has to be frozen or the walk done under a lock.
- A corrupted pointer from memory overwrite can create a cycle that was never in the design. Floyd's detects it, but the real fix is upstream: bounds-checked allocators and sanitizers in test builds.
- A walk with no step limit can spin forever on a malformed structure. I would also cap iterations at the known maximum node count as a second guard.
So the answer is a fast/slow pair, a null-safe loop, and the entry-point reset if they need the start of the cycle, with O(n) time and O(1) space.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Curated: · Written: · Reviewed: