Coding Challenges and Practice Flashcards
7 cards from real CodeSignal Technical Assessment practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Coding Challenges and Practice flashcards as text
A CodeSignal challenge requires implementing an LRU (Least Recently Used) cache with O(1) get and put. Which combination of data structures achieves this?
Answer: Hash map + doubly linked list
A hash map provides O(1) key lookup while a doubly linked list supports O(1) removal and reinsertion to track recency.
In graph problems on CodeSignal, what is topological sorting used for?
Answer: Ordering nodes of a directed acyclic graph so all edges point forward
Topological sort produces a linear ordering of DAG vertices such that every directed edge u→v has u appearing before v.
You are solving a CodeSignal task on interval merging. Given a list of intervals sorted by start time, what is the key condition to merge two intervals?
Answer: The start of the next interval is less than or equal to the end of the current interval
Intervals overlap and should be merged when the next interval's start is ≤ the current merged interval's end.
Which property of a balanced binary search tree ensures O(log n) search time?
Answer: The height is bounded to O(log n) by enforcing balance factors
Balancing constraints (e.g., AVL or Red-Black rules) keep tree height at O(log n), which directly limits search traversal depth.
A CodeSignal problem asks for the number of ways to make change for an amount using given coin denominations. Which DP formulation is correct?
Answer: dp[i] += dp[i - coin] for each coin ≤ i, starting with dp[0] = 1
The unbounded knapsack recurrence dp[i] += dp[i - coin] counts combinations: for each coin, accumulate ways to reach every reachable amount.
In a CodeSignal coding test, you write a function that uses recursion without memoization and times out. What is the most likely cause?
Answer: Overlapping subproblems are being recomputed exponentially
Without memoization, recursive solutions to problems with overlapping subproblems recompute the same values repeatedly, leading to exponential time.
A CodeSignal task provides a directed graph and asks whether it contains a cycle. Which algorithm detects this efficiently?
Answer: DFS with coloring (white/gray/black) to detect back edges
DFS coloring marks nodes as in-progress (gray); encountering a gray node during DFS signals a back edge and thus a cycle.