Axon interview questions & answers

8 real Axon interview questions with full model answers — Coding. Drawn from the same verified bank ChannelPulse drills from (8 Axon questions in total).

CodingEasyAxonSoftware Engineer

1. Valid Palindrome (LeetCode)

Model answer

The task

Determine whether a string reads the same forward and backward after disregarding characters that are not letters or digits and treating uppercase and lowercase as equivalent.

Key idea

Compare characters from both ends, skipping anything that should be ignored. If every remaining pair matches, the string is a palindrome.

Approach

  1. Initialize pointers at the start and end of the string.
  2. Move the left pointer past non-alphanumeric characters.
  3. Move the right pointer past non-alphanumeric characters.
  4. Compare the lowercase forms of the characters at the pointers; return False if they differ.
  5. Move both pointers inward and continue. If they meet or cross, return True.
class Solution:
    def isPalindrome(self, s: str) -> bool:
        left, right = 0, len(s) - 1

        while left < right:
            # Ignore characters that are not letters or digits.
            while left < right and not s[left].isalnum():
                left += 1
            while left < right and not s[right].isalnum():
                right -= 1

            # Compare without regard to letter case.
            if s[left].lower() != s[right].lower():
                return False

            left += 1
            right -= 1

        return True

Complexity:

  • Time: O(n), where n is the string length; each pointer moves only inward.
  • Space: O(1), since the comparisons use no additional data structure.

Common follow-ups

  • What if the input contains no letters or digits? It is considered a palindrome, since there are no mismatching characters.
  • Can you avoid creating a normalized copy of the string? Yes; the two-pointer scan uses constant extra space.
  • How would you handle Unicode normalization? Normalize the string first if canonically equivalent characters should compare as equal; that may require additional space.
CodingMediumAxonSoftware Engineer

2. Interleaving String (LeetCode)

Model answer

The task

Determine whether a target string can be formed by interleaving two source strings. Characters from each source must appear in their original order.

Key idea

Use dynamic programming on prefixes. Let dp[j] mean the first i characters of the first string and first j characters of the second can form the corresponding prefix of the target. For each cell, the last character must come from one of the two sources.

Approach

  1. If the source lengths do not add up to the target length, return False.
  2. Initialize the one-dimensional DP for prefixes using only the second source.
  3. Process the first source one character at a time, updating the DP in place.
  4. For each position, combine the possibility of taking the next character from either source.
  5. Return the DP value for both complete source strings.
class Solution:
    def isInterleave(self, s1: str, s2: str, s3: str) -> bool:
        m, n = len(s1), len(s2)

        if m + n != len(s3):
            return False

        # dp[j] describes using the current prefix of s1
        # together with the first j characters of s2.
        dp = [False] * (n + 1)
        dp[0] = True

        # Match a prefix of s3 using only s2.
        for j in range(1, n + 1):
            dp[j] = dp[j - 1] and s2[j - 1] == s3[j - 1]

        for i in range(1, m + 1):
            # Take the next character from s1, with no characters from s2.
            dp[0] = dp[0] and s1[i - 1] == s3[i - 1]

            for j in range(1, n + 1):
                target_char = s3[i + j - 1]

                # The previous row takes from s1; the current row takes from s2.
                from_s1 = dp[j] and s1[i - 1] == target_char
                from_s2 = dp[j - 1] and s2[j - 1] == target_char
                dp[j] = from_s1 or from_s2

        return dp[n]

Complexity:

  • Time: O(mn), for each pair of source-string prefix lengths.
  • Space: O(n), for the one-dimensional DP array.

Common follow-ups

  • How can the actual interleaving be returned? Store predecessor choices for each DP state, then backtrack from the final state.
  • How can the number of valid interleavings be counted? Replace Boolean states with counts and sum the counts from valid predecessor states.
  • What if one source string is much longer? Use the shorter source for the DP dimension to reduce auxiliary space to O(min(m, n)).
CodingMediumAxonSoftware Engineer

3. Edit Distance (LeetCode)

Model answer

The task

Given two strings, find the fewest single-character insertions, deletions, or replacements needed to change one into the other.

Key idea

Let dp[j] represent the edit distance between the processed prefix of the first string and the first j characters of the second. For each character pair, either keep matching characters at no cost or choose the cheapest insertion, deletion, or replacement.

Approach

  1. Make the second string the shorter one to keep the DP row small.
  2. Initialize distances for converting the empty first prefix into each prefix of the second string.
  3. Process the first string one character at a time, keeping the previous row’s diagonal value.
  4. Update each cell using the matching-character case or the minimum of the three edit operations.
  5. Return the final row value.
class Solution:
    def minDistance(self, word1: str, word2: str) -> int:
        # Keep the DP row as short as possible.
        if len(word2) > len(word1):
            word1, word2 = word2, word1

        # Distances from an empty prefix of word1 to prefixes of word2.
        dp = list(range(len(word2) + 1))

        for i, char1 in enumerate(word1, start=1):
            # Distance from the current word1 prefix to an empty word2 prefix.
            diagonal = dp[0]
            dp[0] = i

            for j, char2 in enumerate(word2, start=1):
                above = dp[j]

                if char1 == char2:
                    dp[j] = diagonal
                else:
                    # Insert, delete, or replace one character.
                    dp[j] = 1 + min(
                        dp[j - 1],  # Insert
                        above,      # Delete
                        diagonal,   # Replace
                    )

                diagonal = above

        return dp[-1]

Complexity:

  • Time: O(mn), where m and n are the string lengths; each pair of characters is processed once.
  • Space: O(min(m, n)), for the DP row.

Common follow-ups

  • How would you reconstruct the actual edits? Store the full DP table, then backtrack from the final cell.
  • What if insertion, deletion, and replacement have different costs? Use those costs in the recurrence.
  • Can the time be reduced when the strings are very different in length? A length difference greater than the allowed edit limit can rule out a result within that limit.
CodingMediumAxonSoftware Engineer

4. Exclusive Time of Functions (LeetCode)

Model answer

The task

Given logs of function calls, return the total time spent executing each function, excluding time spent in functions it calls. Timestamps are discrete, and an end timestamp counts as part of the ending function’s execution.

Key idea

Use a stack to track the active call chain. Keep the first timestamp not yet accounted for; when a call starts or ends, charge the elapsed interval to the function currently on top.

Approach

  1. Create a result array with one entry per function, an empty stack, and prev_time = 0.
  2. Parse each log into a function ID, event type, and timestamp.
  3. On start, charge the interval since prev_time to the current stack top, then push the new function and set prev_time to the timestamp.
  4. On end, charge the inclusive interval through the timestamp to the top function, pop it, and set prev_time to one past the timestamp.
  5. Return the accumulated times.
class Solution:
    def exclusiveTime(self, n: int, logs: list[str]) -> list[int]:
        exclusive = [0] * n
        stack = []
        prev_time = 0

        for log in logs:
            function_id_text, event, timestamp_text = log.split(":")
            function_id = int(function_id_text)
            timestamp = int(timestamp_text)

            if event == "start":
                # The current top function ran until this new call began.
                if stack:
                    exclusive[stack[-1]] += timestamp - prev_time

                stack.append(function_id)
                prev_time = timestamp
            else:
                # The ending function runs through this timestamp, inclusive.
                exclusive[stack.pop()] += timestamp - prev_time + 1
                prev_time = timestamp + 1

        return exclusive

Complexity:

  • Time: O(m + n), for parsing m logs and initializing the result for n functions.
  • Space: O(n + d), for the result array and a stack of maximum depth d.

Common follow-ups

  • What if timestamps are not integers? The inclusive +1 rule would need to be replaced with the problem’s specified interval convention.
  • How would you validate malformed or inconsistent logs? Check event types, function IDs, stack state, and timestamp ordering while processing.
  • Can logs be processed as a stream? Yes; maintain the stack, result totals, and prev_time as persistent state.
CodingMediumAxonSoftware Engineer

5. Insert Delete GetRandom O(1) (LeetCode)

Model answer

The task

Design a collection that supports adding and removing values, plus returning a uniformly random stored value. Each operation should take average O(1) time.

Key idea

Store values in a list for constant-time random indexing, and map each value to its index for fast lookup. To remove an item without shifting the list, swap it with the last item and then pop.

Approach

  1. Keep a list of stored values and a dictionary from value to its list index.
  2. For insertion, return False if the value is already present; otherwise append it and record its index.
  3. For removal, return False if absent. Otherwise, move the last value into the removed value’s slot, update its index, then pop and delete the removed value from the dictionary.
  4. For random selection, choose a uniformly random index in the list.
  5. Assume random selection is called only when the collection is nonempty.
import random

class RandomizedSet:
    def __init__(self):
        self.values = []
        self.index_by_value = {}

    def insert(self, val: int) -> bool:
        if val in self.index_by_value:
            return False

        self.index_by_value[val] = len(self.values)
        self.values.append(val)
        return True

    def remove(self, val: int) -> bool:
        if val not in self.index_by_value:
            return False

        index = self.index_by_value[val]
        last_value = self.values[-1]

        # Fill the removed value's slot with the last value.
        self.values[index] = last_value
        self.index_by_value[last_value] = index

        self.values.pop()
        del self.index_by_value[val]
        return True

    def getRandom(self) -> int:
        return random.choice(self.values)

Complexity:

  • Time: O(1) average per operation; dictionary operations are expected O(1).
  • Space: O(n), for the list and index map storing n values.

Common follow-ups

  • How would you support duplicates? Store each value’s set of indices and update that set during swaps.
  • What if random selection must be weighted? Maintain cumulative weights and use binary search, or use a dynamic weighted-sampling structure.
  • What happens if getRandom is called when empty? Define a clear error or sentinel behavior; the implementation assumes at least one value exists.
CodingMediumAxonSoftware Engineer

6. Design Underground System (LeetCode)

Model answer

The task

Build a system that records passengers checking in and out of stations, then returns the average journey time between any pair of stations.

Key idea

Keep each currently travelling passenger’s start station and check-in time in a hash table. For each station pair, store the total journey time and number of completed journeys; their ratio is the average.

Approach

  1. Map each passenger ID to their check-in station and time.
  2. On check-out, retrieve and remove that passenger’s check-in record.
  3. Use the start and end stations as a route key.
  4. Add the journey duration to that route’s total and increment its journey count.
  5. Return the route’s total divided by its count when asked for an average.
class UndergroundSystem:
    def __init__(self):
        # passenger_id -> (start_station, check_in_time)
        self.check_ins = {}

        # (start_station, end_station) -> [total_time, journey_count]
        self.routes = {}

    def checkIn(self, id: int, stationName: str, t: int) -> None:
        self.check_ins[id] = (stationName, t)

    def checkOut(self, id: int, stationName: str, t: int) -> None:
        start_station, start_time = self.check_ins.pop(id)
        route = (start_station, stationName)

        if route not in self.routes:
            self.routes[route] = [0, 0]

        self.routes[route][0] += t - start_time
        self.routes[route][1] += 1

    def getAverageTime(
        self, startStation: str, endStation: str
    ) -> float:
        total_time, journey_count = self.routes[
            (startStation, endStation)
        ]
        return total_time / journey_count

Complexity:

  • Time: O(1) average per operation, using hash table lookups and updates.
  • Space: O(P + R), where P is the number of passengers currently checked in and R is the number of distinct routes recorded.

Common follow-ups

  • What if a passenger checks in again before checking out? Define whether to reject the operation or replace their active record.
  • How can old route data be removed? Use a retention policy or time-windowed aggregates, depending on reporting needs.
  • How would this work across multiple servers? Partition passengers consistently by ID and aggregate route totals and counts across servers.
CodingMediumAxonSoftware Engineer

7. Time Based Key-Value Store (LeetCode)

Model answer

The task

Design a key-value store that records values with timestamps. A lookup for a key and time returns the value from the latest timestamp not later than the requested time, or an empty string if none exists.

Key idea

Keep each key’s timestamps and values in parallel, ordered by timestamp. Since timestamps for a key arrive in increasing order, writes append in constant time, and lookups use binary search.

Approach

  1. Map each key to a pair of lists: timestamps and corresponding values.
  2. On set, append the timestamp and value to that key’s lists.
  3. On get, use binary search to find the first timestamp greater than the requested time.
  4. Return the value immediately before that position, or an empty string if the position is zero or the key is missing.
from bisect import bisect_right

class TimeMap:
    def __init__(self):
        # Each key maps to its ordered timestamps and matching values.
        self.data: dict[str, tuple[list[int], list[str]]] = {}

    def set(self, key: str, value: str, timestamp: int) -> None:
        if key not in self.data:
            self.data[key] = ([], [])

        timestamps, values = self.data[key]
        timestamps.append(timestamp)
        values.append(value)

    def get(self, key: str, timestamp: int) -> str:
        if key not in self.data:
            return ""

        timestamps, values = self.data[key]
        # The insertion position is just after the latest eligible timestamp.
        index = bisect_right(timestamps, timestamp) - 1

        if index < 0:
            return ""
        return values[index]

Complexity:

  • Time: set is O(1); get is O(log n), where n is the number of entries for that key.
  • Space: O(N), storing all N key-value-timestamp entries.

Common follow-ups

  • What if timestamps arrive out of order? Insert each record at its sorted position, which takes O(n) per write, or use a balanced search tree.
  • How would you reduce memory usage? Expire old records when they can no longer be queried, or compress retained history if the API permits.
  • How would you handle many concurrent reads and writes? Protect updates with synchronization, or use immutable snapshots for read-heavy workloads.
CodingMediumAxonSoftware Engineer

8. K Closest Points to Origin (LeetCode)

Model answer

The task

Given points in a 2D plane and an integer k, return any k points nearest to the origin. Points tied in distance may be returned in any order.

Key idea

Compare squared distances, x² + y²; taking square roots is unnecessary. Keep a max-heap of the k closest points seen so far, so its root is the farthest point currently selected.

Approach

  1. Return an empty list if k is zero.
  2. Add points to a heap, storing negative squared distance so the farthest selected point is at the root.
  3. Once the heap has k points, replace its root whenever a closer point is found.
  4. Return the points referenced by the heap.
import heapq
from typing import List

class Solution:
    def kClosest(self, points: List[List[int]], k: int) -> List[List[int]]:
        if k == 0:
            return []

        # Store (-squared_distance, point_index). The most negative key
        # corresponds to the farthest point, making this a max-heap.
        heap = []

        for i, (x, y) in enumerate(points):
            distance_squared = x * x + y * y

            if len(heap) < k:
                heapq.heappush(heap, (-distance_squared, i))
            elif distance_squared < -heap[0][0]:
                heapq.heapreplace(heap, (-distance_squared, i))

        return [points[i] for _, i in heap]

Complexity:

  • Time: O(n log k), where n is the number of points and each heap update costs O(log k).
  • Space: O(k) for the heap.

Common follow-ups

  • Can sorting solve it? Yes; sort by squared distance in O(n log n) time.
  • Can it be faster on average? Quickselect finds the first k points in expected O(n) time, though its worst case is O(n²).
  • What if points have more dimensions? Sum the squared coordinate differences across all dimensions.
  • How should ties be handled? Any tied points are acceptable unless the question specifies a tie-breaking rule.

Practice these out loud, don't memorise them

Reading an answer is not the same as being able to give one under pressure. ChannelPulse plays the interviewer, asks the follow-ups, and scores each answer with feedback and a model answer so you can hear the gap between what you said and what lands.

Get ChannelPulse Browse all questions