Akamai interview questions & answers

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

CodingEasyAkamaiSoftware Engineer

1. Defuse the Bomb (LeetCode)

Model answer

The task

For each position in a circular array, compute the sum of the next k values when k is positive, or the previous |k| values when k is negative. When k is zero, every result is zero.

Key idea

Maintain the sum of the relevant circular window and update it as the position advances, rather than recalculating each sum. Split |k| into complete cycles and a remainder so the solution also handles values of k larger than the array length.

Approach

  1. Return an empty list for an empty array, and zeros when k is zero.
  2. Split |k| into complete cycles and a remainder; each complete cycle contributes the array’s total sum.
  3. Initialize the remainder window: start after the current position for positive k, or before it for negative k.
  4. Record each result and slide the window by removing the value that leaves and adding the next value.
from typing import List

class Solution:
    def decrypt(self, code: List[int], k: int) -> List[int]:
        n = len(code)
        if n == 0:
            return []
        if k == 0:
            return [0] * n

        count = abs(k)
        cycles, remainder = divmod(count, n)
        full_cycle_sum = cycles * sum(code)
        result = [0] * n

        if k > 0:
            # Initial window contains the next `remainder` values.
            window = sum(code[j % n] for j in range(1, remainder + 1))

            for i in range(n):
                result[i] = full_cycle_sum + window
                # Advance the window to the next position.
                window -= code[(i + 1) % n]
                window += code[(i + remainder + 1) % n]
        else:
            # Initial window contains the previous `remainder` values.
            window = sum(code[-j % n] for j in range(1, remainder + 1))

            for i in range(n):
                result[i] = full_cycle_sum + window
                # Advance the window to the next position.
                window -= code[(i - remainder) % n]
                window += code[i % n]

        return result

Complexity:

  • Time: O(n), since each window is initialized and updated in constant time per position.
  • Space: O(n) for the result; O(1) auxiliary space.

Common follow-ups

  • What if k is zero? Return an array of zeros.
  • What if |k| exceeds the array length? Count full cycles separately, as above.
  • Can the result be produced in place? Only if modifying the input is allowed and its original values remain available during computation.
CodingEasyAkamaiSoftware Engineer

2. Minimum Absolute Difference (LeetCode)

Model answer

The task

Given an integer array, return every pair of values whose absolute difference is as small as possible. Each pair should list its smaller value first.

Key idea

Sort the values. The smallest difference must occur between two neighbors in sorted order: any non-neighboring pair has at least one intervening value and cannot have a smaller gap. A single scan can find the minimum gap and collect all pairs that achieve it.

Approach

  1. Sort the array in ascending order.
  2. Scan adjacent values to find the smallest difference.
  3. Scan adjacent values again, adding each pair whose difference equals that minimum.
  4. Return the collected pairs; the sorted scan produces them in ascending order.
from typing import List

class Solution:
    def minimumAbsDifference(self, arr: List[int]) -> List[List[int]]:
        values = sorted(arr)

        # Find the smallest gap between neighboring values.
        min_gap = min(
            values[i] - values[i - 1]
            for i in range(1, len(values))
        )

        # Collect every neighboring pair with that gap.
        pairs = []
        for i in range(1, len(values)):
            if values[i] - values[i - 1] == min_gap:
                pairs.append([values[i - 1], values[i]])

        return pairs

Complexity:

  • Time: O(n log n), dominated by sorting; the scans take O(n).
  • Space: O(n), for the sorted copy and the returned pairs.

Common follow-ups

  • Can this be done without sorting? Not generally in linear time for arbitrary integers; sorting gives the required order efficiently.
  • What if the input may be modified? Sort arr in place to avoid creating a separate sorted copy.
  • What if values can repeat? Adjacent equal values have gap zero; collect every adjacent pair attaining the minimum.
  • Why are non-neighboring pairs unnecessary? In sorted order, a value between two elements makes their difference at least as large as one of the neighboring gaps.
CodingEasyAkamaiSoftware Engineer

3. Two Sum (LeetCode)

Model answer

The task

Given a list of integers and a target, return the indices of two distinct elements whose values add up to the target. The usual version guarantees a valid pair.

Key idea

As we scan the list, store each value’s index in a hash table. For the current value, check whether its needed complement has already appeared; this finds a pair in one pass.

Approach

  1. Create a dictionary mapping previously seen values to their indices.
  2. For each element, compute the complement needed to reach the target.
  3. If that complement is in the dictionary, return its stored index and the current index.
  4. Otherwise, store the current value and index, then continue.
from typing import List

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        # Map each value already visited to its index.
        seen = {}

        for index, value in enumerate(nums):
            complement = target - value

            # A match must come from an earlier, distinct element.
            if complement in seen:
                return [seen[complement], index]

            seen[value] = index

        # The standard problem guarantees a solution.
        raise ValueError("No two elements sum to the target")

Complexity:

  • Time: O(n), where n is the number of elements; each lookup and insertion is O(1) on average.
  • Space: O(n), for the dictionary of values seen so far.

Common follow-ups

  • What if there may be multiple valid pairs? Return the first pair found, or keep searching and collect pairs according to the required output rules.
  • What if the input is sorted? Use two pointers from opposite ends for O(1) extra space; preserve original indices if those are required.
  • What if values repeat? The dictionary stores indices, and checking before insertion ensures the current element is not paired with itself.
CodingEasyAkamaiSoftware Engineer

4. Longest Palindrome (LeetCode)

Model answer

The task

Given a string of letters, find the greatest length of a palindrome that can be made using its characters. Characters may be rearranged, but each can be used only as many times as it occurs.

Key idea

A palindrome uses characters in pairs, with at most one unpaired character at its center. Count each character, use the largest even number available from every count, and add one to the result if any count is odd.

Approach

  1. Count how many times each character appears.
  2. For every count, add its largest even portion to the palindrome length.
  3. Track whether any count is odd.
  4. If so, add one character for the center.
  5. Return the resulting length.
from collections import Counter

class Solution:
    def longestPalindrome(self, s: str) -> int:
        counts = Counter(s)
        length = 0
        has_odd_count = False

        for count in counts.values():
            # Use all available pairs of this character.
            length += (count // 2) * 2

            if count % 2 == 1:
                has_odd_count = True

        # One leftover character can go in the center.
        if has_odd_count:
            length += 1

        return length

Complexity:

  • Time: O(n), where n is the length of the string.
  • Space: O(k), where k is the number of distinct characters.

Common follow-ups

  • What if the string contains Unicode characters? The same counting approach works; the space depends on the number of distinct characters.
  • Can the palindrome itself be constructed? Build each side from character pairs, then place one leftover character in the center if available.
  • What if characters cannot be rearranged? Then this counting approach does not apply; the problem becomes finding a palindromic subsequence or substring, depending on the requirement.
CodingEasyAkamaiSoftware Engineer

5. Best Time to Buy and Sell Stock (LeetCode)

Model answer

The task

Given daily stock prices, find the greatest profit possible from one buy followed by one later sale. If no sale would make money, return zero.

Key idea

As we scan the prices, keep the lowest price seen so far. Treat each current price as a possible sale and update the best profit using the difference from that minimum.

Approach

  1. Initialize the minimum price to a value larger than any price and the best profit to zero.
  2. Visit each price in order.
  3. Update the minimum price with the current price.
  4. Check the profit from selling today and update the best profit.
  5. Return the best profit.
class Solution:
    def maxProfit(self, prices: list[int]) -> int:
        min_price = float("inf")
        best_profit = 0

        for price in prices:
            # The current price can be a new best day to buy.
            min_price = min(min_price, price)

            # Or it can be the day to sell after the cheapest earlier buy.
            best_profit = max(best_profit, price - min_price)

        return best_profit

Complexity:

  • Time: O(n), where n is the number of prices; each is processed once.
  • Space: O(1), since only a few variables are stored.

Common follow-ups

  • What if multiple buy-and-sell transactions are allowed? Sum the gains from every adjacent price increase.
  • What if a transaction fee is charged? Track the best holding and non-holding profits, incorporating the fee when selling.
  • What if at most k transactions are allowed? Use dynamic programming over the number of completed transactions and whether a share is currently held.
CodingEasyAkamaiSoftware Engineer

6. First Unique Character in a String (LeetCode)

Model answer

The task

Return the index of the first character in a string that occurs exactly once. If no character is unique, return -1.

Key idea

Count how often each character appears, then scan the string from left to right. The first character with a count of one has the smallest qualifying index.

Approach

  1. Build a frequency map by counting every character.
  2. Scan the string in its original order.
  3. Return the index of the first character whose count is one.
  4. If the scan finishes without finding one, return -1.
class Solution:
    def firstUniqChar(self, s: str) -> int:
        # Count the occurrences of each character.
        counts = {}
        for char in s:
            counts[char] = counts.get(char, 0) + 1

        # Return the earliest character that appears once.
        for index, char in enumerate(s):
            if counts[char] == 1:
                return index

        return -1

Complexity:

  • Time: O(n), for counting and scanning the string.
  • Space: O(k), where k is the number of distinct characters stored in the map.

Common follow-ups

  • What if the string is streamed and cannot be revisited? Keep character counts and a queue of candidates; discard candidates once their count exceeds one.
  • What if characters come from a fixed, small alphabet? Use an array of counters instead of a hash map.
  • How would you return the unique character rather than its index? Return char at the matching position, with an appropriate sentinel if none exists.
CodingEasyAkamaiSoftware Engineer

7. N-Repeated Element in Size 2N Array (LeetCode)

Model answer

The task

Given an array of length 2N, where one value appears N times and every other value appears once, return the value that appears N times.

Key idea

Track values seen so far in a set. The repeated value is the first one encountered a second time.

Approach

  1. Create an empty set.
  2. Scan the array from left to right.
  3. If the current value is already in the set, return it.
  4. Otherwise, add it to the set.
from typing import List

class Solution:
    def repeatedNTimes(self, nums: List[int]) -> int:
        seen = set()

        for value in nums:
            if value in seen:
                return value
            seen.add(value)

        # The problem guarantees a repeated value.
        raise ValueError("No repeated value found")

Complexity:

  • Time: O(N) — each of the 2N values is checked once.
  • Space: O(N) — the set stores distinct values seen before the repeat.

Common follow-ups

  • Can this use constant extra space? Yes; compare values in short windows, since the repeated value must occur close together.
  • What if several values can repeat? Count occurrences with a hash map and return the value meeting the required threshold.
  • What if the input is streamed? Keep a set of seen values and stop as soon as one appears again.
CodingEasyAkamaiSoftware Engineer

8. Add Two Integers (LeetCode)

Model answer

The task

Return the sum of two integers.

Key idea

Integer addition directly gives the result. No iteration or extra data structures are needed.

Approach

  1. Accept the two integer arguments.
  2. Add them using +.
  3. Return the result.
class Solution:
    def sum(self, num1: int, num2: int) -> int:
        # Return the sum of the two integers.
        return num1 + num2

Complexity:

  • Time: O(1), since addition takes constant time for fixed-width integers.
  • Space: O(1), as no additional storage is used.

Common follow-ups

  • What if one or both integers are negative? The same addition works.
  • How would you add without using +? Use bitwise operations to compute carry and partial sums.
  • What if the integers are extremely large? Use arbitrary-precision integers, or a representation suited to the required size.
CodingMediumAkamaiSoftware Engineer

9. Course Schedule (LeetCode)

Model answer

The task

Given a number of courses and prerequisite pairs, decide whether it’s possible to complete every course. A prerequisite pair means one course must be taken before another.

Key idea

Represent courses as a directed graph, with an edge from each prerequisite to the course that depends on it. A cycle means the courses in that cycle depend on one another, so not all courses can be completed.

Use Kahn’s topological-sort algorithm: repeatedly take courses with no remaining prerequisites and remove their outgoing edges.

Approach

  1. Create an adjacency list and count each course’s prerequisites (its indegree).
  2. Add every course with indegree zero to a queue.
  3. Remove courses from the queue, counting each as completed.
  4. Decrease the indegree of each dependent course; enqueue it when its indegree reaches zero.
  5. Return whether the number completed equals the total number of courses.
from collections import deque
from typing import List

class Solution:
    def canFinish(
        self, numCourses: int, prerequisites: List[List[int]]
    ) -> bool:
        # Edges point from prerequisite to the course that depends on it.
        graph = [[] for _ in range(numCourses)]
        indegree = [0] * numCourses

        for course, prerequisite in prerequisites:
            graph[prerequisite].append(course)
            indegree[course] += 1

        # Begin with courses that have no prerequisites.
        ready = deque(
            course
            for course in range(numCourses)
            if indegree[course] == 0
        )

        completed = 0

        while ready:
            course = ready.popleft()
            completed += 1

            for dependent in graph[course]:
                indegree[dependent] -= 1
                if indegree[dependent] == 0:
                    ready.append(dependent)

        return completed == numCourses

Complexity:

  • Time: O(V + E), where V is the number of courses and E is the number of prerequisite pairs.
  • Space: O(V + E) for the graph, indegrees, and queue.

Common follow-ups

  • How can you return a valid course order? Record courses as they are removed from the queue; return the order if it includes every course.
  • How can DFS detect a cycle? Track nodes as unvisited, visiting, or finished; reaching a visiting node reveals a cycle.
  • What if there are no courses? The algorithm returns True, since zero courses can all be completed.
CodingMediumAkamaiSoftware Engineer

10. Spiral Matrix (LeetCode)

Model answer

The task

Return the matrix values in clockwise spiral order, starting from the top-left corner and moving inward.

Key idea

Track the unvisited rectangle with four boundaries. Visit its top, right, bottom, and left edges in turn, then shrink the rectangle and repeat.

Approach

  1. Return an empty list if the matrix has no rows or columns.
  2. Initialize boundaries for the top, bottom, left, and right edges.
  3. Traverse the top edge, then move the top boundary inward.
  4. Traverse the right edge, then move the right boundary inward.
  5. If rows remain, traverse the bottom edge in reverse; if columns remain, traverse the left edge upward.
  6. Repeat until the boundaries cross.
from typing import List

class Solution:
    def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
        if not matrix or not matrix[0]:
            return []

        result = []
        top, bottom = 0, len(matrix) - 1
        left, right = 0, len(matrix[0]) - 1

        while top <= bottom and left <= right:
            # Traverse the top edge from left to right.
            for col in range(left, right + 1):
                result.append(matrix[top][col])
            top += 1

            # Traverse the right edge from top to bottom.
            for row in range(top, bottom + 1):
                result.append(matrix[row][right])
            right -= 1

            # Traverse the bottom edge only if it has not been visited.
            if top <= bottom:
                for col in range(right, left - 1, -1):
                    result.append(matrix[bottom][col])
                bottom -= 1

            # Traverse the left edge only if it has not been visited.
            if left <= right:
                for row in range(bottom, top - 1, -1):
                    result.append(matrix[row][left])
                left += 1

        return result

Complexity: Time: O(m × n), where each cell is visited once.

Complexity: Space: O(1) auxiliary space, excluding the output list.

Common follow-ups

  • How would you return the values counterclockwise? Change the traversal order and edge directions while maintaining the same boundary updates.
  • How does this handle a single row or column? The boundary checks prevent an edge from being visited twice.
  • Can the traversal be done without boundary variables? Yes, by marking visited cells and turning when blocked, but that requires O(m × n) extra space.
CodingMediumAkamaiSoftware Engineer

11. Palindromic Substrings (LeetCode)

Model answer

The task

Given a string, count how many of its substrings are palindromes. Count each substring by its position, so equal text at different positions contributes more than once.

Key idea

Every palindrome has a center: either one character or the gap between two characters. Expand outward from each possible center while the characters match, counting each palindrome found.

Approach

  1. Initialize a counter for the palindromic substrings.
  2. Visit each character position as an odd-length center.
  3. Visit each gap between adjacent characters as an even-length center.
  4. For each center, expand left and right while the characters match, adding one to the counter for each match.
  5. Return the counter.
class Solution:
    def countSubstrings(self, s: str) -> int:
        count = 0
        n = len(s)

        def expand(left: int, right: int) -> int:
            found = 0

            # Every matching expansion forms another palindrome.
            while left >= 0 and right < n and s[left] == s[right]:
                found += 1
                left -= 1
                right += 1

            return found

        for center in range(n):
            # Odd-length palindromes centered on one character.
            count += expand(center, center)

            # Even-length palindromes centered between characters.
            count += expand(center, center + 1)

        return count

Complexity:

  • Time: O(n²), since each of the O(n) centers can expand across O(n) characters.
  • Space: O(1), using only a counter and a few indices.

Common follow-ups

  • How would you find the longest palindromic substring? Track the longest span found during each expansion.
  • How would you count distinct palindrome values instead of occurrences? Store the distinct palindrome strings in a set; this can require O(n²) space.
  • Can this be solved with dynamic programming? Yes: record whether each interval is a palindrome based on its end characters and its inner interval, using O(n²) time and space.
CodingMediumAkamaiSoftware Engineer

12. Contiguous Array (LeetCode)

Model answer

The task

Given a binary array, find the length of its longest contiguous segment containing the same number of zeroes and ones.

Key idea

Treat each zero as −1 and each one as +1. A segment has equal counts precisely when its sum is zero, which happens when two prefix sums are equal. Store the earliest index for each prefix sum so each match gives the longest segment ending at the current index.

Approach

  1. Initialize the prefix balance to zero and record its earliest position as −1.
  2. Scan the array, adding +1 for a one and −1 for a zero.
  3. If the balance has appeared before, update the best length using the distance from its earliest position.
  4. Otherwise, record the current index for that balance.
  5. Return the best length.
class Solution:
    def findMaxLength(self, nums: list[int]) -> int:
        # The initial balance occurs just before the array starts.
        first_index = {0: -1}
        balance = 0
        longest = 0

        for index, value in enumerate(nums):
            balance += 1 if value == 1 else -1

            if balance in first_index:
                longest = max(longest, index - first_index[balance])
            else:
                # Keep the earliest position to maximize future segment lengths.
                first_index[balance] = index

        return longest

Complexity:

  • Time: O(n), where n is the array length; each element is processed once.
  • Space: O(n) in the worst case, for the stored prefix balances.

Common follow-ups

  • How would you return the segment’s start and end indices? Track the pair of indices for the best length when updating it.
  • What if the array contains values beyond zero and one? The same method works if the goal is equal counts of two selected values; map one to +1, the other to −1, and ignore or separately handle other values as required.
  • Can the method use less space? Not generally for arbitrary input in one pass; prefix balances may all be distinct, so the map can grow to O(n).
CodingMediumAkamaiSoftware Engineer

13. Find Peak Element (LeetCode)

Model answer

The task

Given an array whose neighboring values are distinct, return the index of any element that is greater than its neighbors. Treat positions outside the array as having value negative infinity.

Key idea

Compare the middle element with the one immediately to its right. If the middle is larger, a peak exists at or to its left; otherwise, a peak exists to its right. This lets binary search discard half the search range each iteration.

Approach

  1. Set left and right to the array’s endpoints.
  2. While the range has more than one element, inspect its midpoint and the next element.
  3. If the midpoint is larger, keep the left half, including the midpoint.
  4. Otherwise, keep the right half, starting after the midpoint.
  5. Return the remaining index.
class Solution:
    def findPeakElement(self, nums: list[int]) -> int:
        left, right = 0, len(nums) - 1

        while left < right:
            mid = (left + right) // 2

            # A descending step means a peak is at mid or somewhere to its left.
            if nums[mid] > nums[mid + 1]:
                right = mid
            else:
                # An ascending step means a peak exists to the right of mid.
                left = mid + 1

        return left

Complexity:

  • Time: O(log n), since the search range is halved each iteration.
  • Space: O(1), since only a fixed number of variables are used.

Common follow-ups

  • How would you return all peak indices? Scan the array and compare each value with its neighbors, using negative infinity at the boundaries.
  • What if adjacent values may be equal? The binary-search reasoning may no longer identify a peak in logarithmic time; handle plateaus explicitly or scan in O(n).
  • How would you find a peak in a two-dimensional grid? Use binary search across columns, finding a column maximum each step and comparing it with its horizontal neighbors.
CodingMediumAkamaiSoftware Engineer

14. Unique Paths (LeetCode)

Model answer

The task

Count the routes from the upper-left to the lower-right of an m-by-n grid when each move goes either right or down.

Key idea

The number of ways to reach a cell is the sum of the ways to reach the cell above and the cell to its left. Keep only one row of counts, since each update needs just those two values.

Approach

  1. Make the smaller grid dimension the stored row to reduce space.
  2. Initialize every cell in the first row to one: there is only one way to move right along it.
  3. For each later row, update each cell by adding the count from its left to the count already stored from above.
  4. Return the count at the final cell.
class Solution:
    def uniquePaths(self, m: int, n: int) -> int:
        # Keep the DP array as short as possible.
        if m < n:
            m, n = n, m

        # The first row has one way to reach each cell.
        paths = [1] * n

        # Update each row using the value above and the value to the left.
        for _ in range(1, m):
            for col in range(1, n):
                paths[col] += paths[col - 1]

        return paths[-1]

Complexity:

  • Time: O(mn), updating each cell once.
  • Space: O(min(m, n)), storing one row of counts.

Common follow-ups

  • How would you handle blocked cells? Set a blocked cell’s count to zero as each row is updated.
  • Can you compute the count without dynamic programming? Use the binomial coefficient C(m + n - 2, m - 1), since every route consists of a fixed number of down and right moves.
  • What if only the number of routes using exactly k turns is needed? Extend the state to track the last move direction and the number of turns.
CodingMediumAkamaiSoftware Engineer

15. Longest Substring Without Repeating Characters (LeetCode)

Model answer

The task

Find the length of the longest contiguous section of a string in which every character appears at most once.

Key idea

Maintain a sliding window with no repeated characters. When a character repeats within the window, move the left edge just past its previous occurrence.

Approach

  1. Track each character’s most recent index in a dictionary.
  2. Keep left as the window’s starting index and best as its longest length so far.
  3. For each character, move left forward if its previous occurrence is inside the current window.
  4. Record the character’s current index and update best using the window length.
class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        last_seen = {}
        left = 0
        best = 0

        for right, char in enumerate(s):
            # Skip past a repeated character if it is in the current window.
            if char in last_seen and last_seen[char] >= left:
                left = last_seen[char] + 1

            last_seen[char] = right
            best = max(best, right - left + 1)

        return best

Complexity:

  • Time: O(n), because each character is processed once.
  • Space: O(k), where k is the number of distinct characters encountered.

Common follow-ups

  • Return the substring itself: store the best window’s start and end indices when updating best.
  • Handle a stream of characters: keep the same window state and process each arriving character incrementally.
  • Use a fixed-size character set: replace the dictionary with an array of last-seen indices.

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