NetApp interview questions & answers

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

CodingEasyNetAppSoftware Engineer

1. Rotate String (LeetCode)

Model answer

The task

Determine whether one string can be obtained by repeatedly moving the first character of another string to its end. The resulting string must match exactly.

Key idea

A rotation of s appears as a substring of s + s. Check for that match using KMP string matching, which runs in linear time.

Approach

  1. If the strings have different lengths, they cannot be rotations.
  2. Build the KMP prefix table for the target string.
  3. Scan s + s with KMP, returning True if the target is found.
  4. Return False if the scan finishes without a match.
class Solution:
    def rotateString(self, s: str, goal: str) -> bool:
        if len(s) != len(goal):
            return False
        if not goal:
            return True

        # Build the KMP prefix table: the longest proper prefix that
        # is also a suffix for each prefix of goal.
        prefix = [0] * len(goal)
        matched = 0

        for i in range(1, len(goal)):
            while matched and goal[i] != goal[matched]:
                matched = prefix[matched - 1]
            if goal[i] == goal[matched]:
                matched += 1
                prefix[i] = matched

        # Search for goal in the doubled string.
        matched = 0
        for char in s + s:
            while matched and char != goal[matched]:
                matched = prefix[matched - 1]
            if char == goal[matched]:
                matched += 1
                if matched == len(goal):
                    return True

        return False

Complexity:

  • Time: O(n), for building the prefix table and scanning the doubled string.
  • Space: O(n), for the prefix table.

Common follow-ups

  • Can you use a built-in string search instead? Yes: check whether goal occurs in s + s; KMP gives an explicit linear-time bound.
  • What if the strings have different lengths? They cannot be rotations, so return False immediately.
  • Does the empty string match itself? Yes; zero rotations leave it unchanged.
CodingEasyNetAppSoftware Engineer

2. 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.
CodingEasyNetAppSoftware Engineer

3. 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.
CodingEasyNetAppSoftware Engineer

4. Move Zeroes (LeetCode)

Model answer

The task

Rearrange an integer array in place so all zeroes come after the nonzero values. Keep the nonzero values in their original relative order.

Key idea

Use a write pointer to mark where the next nonzero value belongs. Scan the array once, swapping each nonzero value into that position; this keeps the nonzero values stable and uses constant extra space.

Approach

  1. Set write to the first available position for a nonzero value.
  2. Scan each index from left to right.
  3. When a nonzero value is found, swap it with the value at write.
  4. Advance write after each nonzero value.
  5. Once the scan ends, all remaining positions contain zeroes.
from typing import List

class Solution:
    def moveZeroes(self, nums: List[int]) -> None:
        # The next nonzero value belongs at index write.
        write = 0

        for read in range(len(nums)):
            if nums[read] != 0:
                nums[write], nums[read] = nums[read], nums[write]
                write += 1

Complexity:

  • Time: O(n), where n is the array length; each value is examined once.
  • Space: O(1), since rearrangement is done in place.

Common follow-ups

  • What if relative order does not matter? Partitioning zeroes and nonzeroes can be done with two pointers, potentially with fewer assignments.
  • Can you reduce unnecessary writes? Swap only when read != write; this avoids self-swaps.
  • What if the input is a linked list? Relink nonzero nodes in their original order, then append the zero-valued nodes.
CodingMediumNetAppSoftware Engineer

5. Combination Sum (LeetCode)

Model answer

The task

Given positive candidate values and a target, find every distinct combination that sums to the target. A candidate may be used multiple times, but combinations that differ only in order should appear once.

Key idea

Build each combination in nondecreasing candidate order. After choosing a value, recurse from its same index so it can be reused; this ordering prevents permutations from being generated.

Approach

  1. Sort the candidates to process them in ascending order and enable early stopping.
  2. Use backtracking with the current start index, remaining sum, and chosen values.
  3. When the remaining sum is zero, save a copy of the chosen values.
  4. Otherwise, try each candidate from the start index onward.
  5. Stop trying larger candidates once one exceeds the remaining sum.
from typing import List

class Solution:
    def combinationSum(
        self, candidates: List[int], target: int
    ) -> List[List[int]]:
        candidates.sort()
        results: List[List[int]] = []
        current: List[int] = []

        def search(start: int, remaining: int) -> None:
            if remaining == 0:
                results.append(current.copy())
                return

            for index in range(start, len(candidates)):
                value = candidates[index]

                # Later values are no smaller, so none can fit either.
                if value > remaining:
                    break

                current.append(value)
                # Keep index unchanged to allow reusing this candidate.
                search(index, remaining - value)
                current.pop()

        search(0, target)
        return results

Complexity:

  • Time: O(N^d + R·d) as a loose worst-case bound, where N is the number of candidates, d = target / smallest candidate, and R is the number of results. The search explores candidate sequences up to depth d.
  • Space: O(d) auxiliary space for the recursion and current combination, excluding the returned results.

Common follow-ups

  • How would you avoid duplicate combinations if the input can contain repeated values? Deduplicate the sorted candidates before searching.
  • How would you find just one combination? Return immediately when a successful path is found.
  • What if each candidate can be used at most once? Recurse with index + 1 instead of index.
  • How can you handle a very large target? Use dynamic programming or memoization if the goal is counting or checking existence rather than listing every combination.
CodingMediumNetAppSoftware Engineer

6. 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.
CodingMediumNetAppSoftware Engineer

7. Longest Well-Performing Interval (LeetCode)

Model answer

The task

Find the length of the longest consecutive interval in which days with more than 8 hours of work outnumber the other days.

Key idea

Convert each day into +1 if it is tiring and -1 otherwise. An interval is well-performing exactly when its sum is positive, so the goal becomes finding the longest subarray with a positive sum.

Use prefix sums and a stack of indices where the prefix sum reaches a new minimum. These are the only starting points that can help form the longest interval.

Approach

  1. Build prefix sums, including the initial sum before any days.
  2. Store an index when its prefix sum is strictly smaller than all earlier stored prefix sums.
  3. Scan prefix indices from right to left.
  4. While the current prefix sum is greater than the sum at the top stack index, the pair forms a positive-sum interval. Update the best length and remove that starting index.
  5. Return the maximum length found.
from typing import List

class Solution:
    def longestWPI(self, hours: List[int]) -> int:
        n = len(hours)

        # Prefix sum at each boundary between days.
        prefix = [0] * (n + 1)
        for i, hour in enumerate(hours):
            score = 1 if hour > 8 else -1
            prefix[i + 1] = prefix[i] + score

        # Candidate starts: indices with strictly decreasing prefix sums.
        candidates = []
        for i, value in enumerate(prefix):
            if not candidates or value < prefix[candidates[-1]]:
                candidates.append(i)

        longest = 0

        # Try each boundary as the interval's right endpoint.
        for right in range(n, -1, -1):
            while candidates and prefix[right] > prefix[candidates[-1]]:
                left = candidates.pop()
                longest = max(longest, right - left)

        return longest

Complexity:

  • Time: O(n), since each prefix index is pushed and popped at most once.
  • Space: O(n), for the prefix sums and candidate stack.

Common follow-ups

  • Return the interval as well as its length: Store the (left, right) boundaries whenever the best length increases.
  • Change the tiring-day threshold: Replace hour > 8 with the new condition; the +1/-1 reduction still applies.
  • Process days as a stream: Keep prefix information and earliest candidate indices as data arrives; previously finalized endpoints do not need to be revisited.
CodingMediumNetAppSoftware Engineer

8. Reconstruct Original Digits from English (LeetCode)

Model answer

The task

Given a string of letters formed by writing out several English number names from zero through nine, recover the digits and return them in ascending order.

Key idea

Certain letters appear in only one number name, so their counts identify some digits immediately. Subtract those digits’ letters from the shared-letter counts to determine the rest.

Approach

  1. Count each letter in the input.
  2. Identify zero, two, four, six, and eight using their unique letters: z, w, u, x, and g.
  3. Find three, five, and seven using h, f, and s, subtracting the already-counted eight, four, and six.
  4. Find one from the remaining o count, and nine from the remaining i count.
  5. Build the result by appending each digit according to its count, in ascending order.
from collections import Counter

class Solution:
    def originalDigits(self, s: str) -> str:
        letters = Counter(s)
        digits = [0] * 10

        # Digits identifiable by letters unique among the number names.
        digits[0] = letters["z"]
        digits[2] = letters["w"]
        digits[4] = letters["u"]
        digits[6] = letters["x"]
        digits[8] = letters["g"]

        # Resolve digits whose identifying letters are shared.
        digits[3] = letters["h"] - digits[8]
        digits[5] = letters["f"] - digits[4]
        digits[7] = letters["s"] - digits[6]
        digits[1] = letters["o"] - digits[0] - digits[2] - digits[4]
        digits[9] = letters["i"] - digits[5] - digits[6] - digits[8]

        return "".join(str(digit) * count for digit, count in enumerate(digits))

Complexity:

  • Time: O(n), to count the letters and build the result.
  • Space: O(n) for the returned string; the letter counts use O(1) auxiliary space because the alphabet is fixed.

Common follow-ups

  • What if the output need not be sorted? Append digits as they are identified, or keep the same counts and change the final construction.
  • How would you validate the input? Reconstruct the letter counts from the computed digits and compare them with the original counts.
  • Can this handle number names in another language? Yes, with that language’s spellings and a suitable set of distinguishing letters or another counting strategy.
CodingMediumNetAppSoftware Engineer

9. LRU Cache (LeetCode)

Model answer

The task

Design a cache with a fixed capacity that supports retrieving and inserting key-value pairs. When an insertion exceeds capacity, evict the item that has gone unused for the longest time.

Key idea

Use a hash map for direct key lookup and a doubly linked list to track recency. Keep the most recently used item at the front; the least recently used item is at the back.

Approach

  1. Create a map from keys to their linked-list nodes.
  2. Use dummy head and tail nodes so items can be added or removed without special cases at the ends.
  3. On a successful get, move the node to the front and return its value; return -1 if the key is absent.
  4. On put, update and promote an existing node, or add a new node at the front.
  5. If the cache is over capacity, remove the node just before the tail and delete its key from the map.
class _Node:
    def __init__(self, key: int = 0, value: int = 0):
        self.key = key
        self.value = value
        self.prev = None
        self.next = None

class LRUCache:
    def __init__(self, capacity: int):
        self.capacity = capacity
        self.nodes = {}

        # Items are stored between these sentinels.
        self.head = _Node()
        self.tail = _Node()
        self.head.next = self.tail
        self.tail.prev = self.head

    def _remove(self, node: _Node) -> None:
        node.prev.next = node.next
        node.next.prev = node.prev

    def _add_to_front(self, node: _Node) -> None:
        node.prev = self.head
        node.next = self.head.next
        self.head.next.prev = node
        self.head.next = node

    def _make_most_recent(self, node: _Node) -> None:
        self._remove(node)
        self._add_to_front(node)

    def get(self, key: int) -> int:
        node = self.nodes.get(key)
        if node is None:
            return -1

        self._make_most_recent(node)
        return node.value

    def put(self, key: int, value: int) -> None:
        node = self.nodes.get(key)

        if node is not None:
            node.value = value
            self._make_most_recent(node)
            return

        node = _Node(key, value)
        self.nodes[key] = node
        self._add_to_front(node)

        if len(self.nodes) > self.capacity:
            least_recent = self.tail.prev
            self._remove(least_recent)
            del self.nodes[least_recent.key]

Complexity:

  • Time: O(1) for get and put; map and list operations take constant time.
  • Space: O(capacity); the map and list store at most the cache’s capacity of entries.

Common follow-ups

  • How would you make the cache thread-safe? Protect operations with a lock.
  • What if entries expire after a time-to-live? Track expiration times and remove expired entries during access or with a cleanup mechanism.
  • How would you support eviction by frequency instead of recency? Track access counts and organize entries by frequency.
CodingMediumNetAppSoftware Engineer

10. Find First and Last Position of Element in Sorted Array (LeetCode)

Model answer

The task

Given a sorted array and a target value, return the indices of its first and last occurrences. If the target is absent, return [-1, -1].

Key idea

Use binary search twice: once to find the first index whose value is at least the target, and once to find the first index whose value is greater than the target. The second boundary, minus one, is the target’s last index.

Approach

  1. Write a binary search that finds the first index meeting a chosen comparison.
  2. Find the first index with a value at least the target.
  3. If that index is past the array or does not contain the target, return [-1, -1].
  4. Find the first index with a value greater than the target.
  5. Return the first index and the second boundary minus one.
from typing import List

class Solution:
    def searchRange(self, nums: List[int], target: int) -> List[int]:
        def first_index(strictly_greater: bool) -> int:
            """Return the first index with value > target, or >= target."""
            left, right = 0, len(nums)

            while left < right:
                mid = (left + right) // 2
                qualifies = (
                    nums[mid] > target
                    if strictly_greater
                    else nums[mid] >= target
                )

                if qualifies:
                    right = mid
                else:
                    left = mid + 1

            return left

        first = first_index(strictly_greater=False)

        if first == len(nums) or nums[first] != target:
            return [-1, -1]

        after_last = first_index(strictly_greater=True)
        return [first, after_last - 1]

Complexity:

  • Time: O(log n), from two binary searches.
  • Space: O(1), excluding the returned list.

Common follow-ups

  • Can the search be done with one binary search? A single search finds only one occurrence; additional work is needed to locate both boundaries.
  • What if the array is empty? The first boundary is zero, so the method returns [-1, -1].
  • How would you count occurrences instead? Subtract the first index from the first index greater than the target.
CodingMediumNetAppSoftware Engineer

11. Rank Teams by Votes (LeetCode)

Model answer

The task

Given ballots that list the same teams in preference order, rank teams by how often they appear in each position. Break any remaining tie alphabetically.

Key idea

For each team, count its votes at every position. Compare teams by their count vectors from first position to last, in descending order, using alphabetical order as the final tie-breaker.

Approach

  1. Get the teams and number of positions from the first ballot.
  2. Create a count vector for each team.
  3. For every ballot, increment the count for each team at its position.
  4. Sort teams by their count vectors, highest counts first, then alphabetically.
  5. Return the sorted team names as a string.
class Solution:
    def rankTeams(self, votes: list[str]) -> str:
        teams = votes[0]
        positions = len(teams)

        # counts[team][position] stores votes for that team at that rank.
        counts = {team: [0] * positions for team in teams}

        for ballot in votes:
            for position, team in enumerate(ballot):
                counts[team][position] += 1

        # Negate counts so Python's ascending sort puts larger counts first.
        ranked = sorted(
            teams,
            key=lambda team: tuple(-count for count in counts[team]) + (team,),
        )

        return "".join(ranked)

Complexity:

  • Time: O(V · T + T² log T), where V is the number of ballots and T is the number of teams.
  • Space: O(T²) for the per-team position counts.

Common follow-ups

  • What if teams can have different numbers of positions? Define how missing positions should be counted, then normalize ballots before tallying.
  • How would you rank a very large number of ballots? Tally counts incrementally as ballots arrive; the final sort is still needed for the ranking.
  • What if alphabetical order is replaced by a custom priority? Use that priority as the final sort tie-breaker.
CodingMediumNetAppSoftware Engineer

12. 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