← ansys Interview Insights

ansys·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Coding interview for a software engineer role at Ansys with two problems back to back. Nothing too wild but the follow-up on the first one tripped me up a bit.

Questions Asked (2)

Q1

Design a data structure that supports inserting strings and counting how many stored strings share a given prefix. Follow-up: how would you make the search case-insensitive, and how would you strip trailing digits from inputs before storing or querying?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The core trie implementation wasn't too bad, I got through insert and prefix count without much trouble.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by proposing a trie (prefix tree) as the core data structure, explaining how each node stores a count of strings passing through it to support prefix counting in O(L) time. Then address the follow-ups by normalizing inputs: for case-insensitivity, lowercase all characters before insertion and query; for stripping trailing digits, preprocess strings to remove trailing digits before any operation. Discuss trade-offs such as memory overhead and potential alternatives like hash maps with prefix keys.

Pro tip: Mention that the trie can be augmented with a count at each node to avoid traversing the entire subtree, and that normalization should be applied consistently to both insertions and queries to maintain correctness. Also, consider edge cases like empty strings and strings that become empty after stripping digits.

1. Clarify requirements and constraints

Ask about expected input size, character set, and whether updates (deletions) are needed. Confirm that prefix counting should be exact and efficient.

2. Propose trie with node counts

Describe a trie where each node has a count of how many strings pass through it. Insertion increments counts along the path; prefix query traverses to the prefix node and returns its count.

3. Analyze complexity and trade-offs

State that insertion and query take O(L) time where L is string length, and memory is O(total characters). Compare with alternatives like hash maps storing all prefixes, which use more space but may be faster for certain queries.

4. Handle case-insensitivity

Normalize all input strings to lowercase (or uppercase) before insertion and query. This ensures that 'Apple' and 'apple' are treated the same.

5. Strip trailing digits

Preprocess strings by removing trailing digits (e.g., using a regex or loop) before insertion and query. Ensure this is done consistently and consider edge cases like strings that become empty.

Key Points to Mention

  • Trie (prefix tree) structure and its O(L) time complexity for insert and prefix count.
  • Storing a count at each node to avoid traversing the subtree for counting.
  • Normalization (lowercasing) for case-insensitive search, applied to both insert and query.
  • Stripping trailing digits via preprocessing, with consistent application to inserts and queries.
  • Trade-offs: memory overhead of trie vs. hash map with prefix keys; potential for compression (radix tree).
  • Edge cases: empty strings, strings that become empty after stripping digits, and non-alphanumeric characters.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Given the head of a singly linked list and a target value, remove all nodes with that value and return the new head.

Algorithms & Data Structures
Author's notes

Pretty standard linked list removal.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying edge cases like an empty list or removing the head, then propose a two-pointer (prev/curr) traversal with a dummy head to simplify head removal. Walk through the pointer updates, analyze O(n) time and O(1) space, and test with examples including consecutive removals.

Pro tip: Use a dummy node pointing to the head to avoid special-casing head removal, and explicitly mention that you're not freeing memory in languages like C/C++ unless asked—this shows awareness of memory management.

1. Clarify requirements and edge cases

Ask about empty list, all nodes matching, no matches, and whether the list is singly linked. Confirm if memory deallocation is needed.

2. Choose the right technique

Propose using a dummy head node and two pointers (prev and curr) to handle removal uniformly, including the head.

3. Walk through the algorithm

Initialize dummy.next = head, prev = dummy, curr = head. While curr, if curr.val == target, set prev.next = curr.next; else prev = curr. Move curr = curr.next. Return dummy.next.

4. Analyze complexity and test

State O(n) time and O(1) space. Test with examples: empty list, head removal, consecutive removals, and no removal.

Key Points to Mention

  • Dummy head node to simplify edge cases
  • Two-pointer traversal (prev and curr)
  • Time complexity O(n) and space complexity O(1)
  • Handling consecutive target nodes correctly
  • Returning the new head (dummy.next)
  • Memory management considerations in C/C++

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.