Grammarly

Grammarly Software Engineer Interview Questions

24+ questions from real Grammarly Software Engineer interviews, reported by candidates.

24
Questions
5
Round Types
8
Topic Areas
2025
Year Range

Round Types

Phone 9 Coding 9 Onsite 3 Phone Screen 2 Recruiter 1

Top Topics

Questions

Two questions for easy eloquence Drinking slurry Bad drinking period

Has anyone recently had a Grammarly VO interview? They didn't have any in-person interviews throughout 2025. Ideally, it would be a Best-in-Class (BE) interview. Thank you so much! I'll give you point

The phone interview lasted one hour. The interviewer was a very friendly MIT girl (ABC). She had worked at her original startup for almost a year after it was acquired by the Grammys. The interview co

LeetCode #56: Merge Intervals. Difficulty: Medium. Topics: Array, Sorting. Asked at Grammarly in the last 6 months.

LeetCode #1047: Remove All Adjacent Duplicates In String. Difficulty: Easy. Topics: String, Stack. Asked at Grammarly in the last 6 months.

LeetCode #966: Vowel Spellchecker. Difficulty: Medium. Topics: Array, Hash Table, String. Asked at Grammarly in the last 6 months.

LeetCode #380: Insert Delete GetRandom O(1). Difficulty: Medium. Topics: Array, Hash Table, Math, Design, Randomized. Asked at Grammarly in the last 6 months.

LeetCode #35: Search Insert Position. Difficulty: Easy. Topics: Array, Binary Search. Asked at Grammarly in the last 6 months.

LeetCode #359: Logger Rate Limiter. Difficulty: Easy. Topics: Hash Table, Design, Data Stream. Asked at Grammarly in the last 6 months.

LeetCode #404: Sum of Left Leaves. Difficulty: Easy. Topics: Tree, Depth-First Search, Breadth-First Search, Binary Tree. Asked at Grammarly in the last 6 months.

LeetCode #150: Evaluate Reverse Polish Notation. Difficulty: Medium. Topics: Array, Math, Stack. Asked at Grammarly in the last 6 months.

LeetCode #435: Non-overlapping Intervals. Difficulty: Medium. Topics: Array, Dynamic Programming, Greedy, Sorting. Asked at Grammarly in the last 6 months.

## Problem Given a string `s` and an integer `k`, return all unique substrings of exactly length `k`, sorted lexicographically. ```python def all_k_substrings(s: str, k: int) -> List[str]: ... ``` **Example:** ``` Input: s="abcabc", k=3 Output: ["abc", "bca", "cab"] # Sliding window gives: "abc","bca","cab","abc" -> unique sorted Input: s="aaaa", k=2 Output: ["aa"] Input: s="ab", k=5 Output: [] # k > len(s) ``` ## Approach Slide a window of size `k` across `s` and collect all substrings into a set, then sort. Time O(n*k) for hashing, O(m log m * k) for sorting where m = number of unique substrings. ## Follow-ups 1. How would you use a rolling hash to reduce per-window work to O(1)? 2. If `k` is very large and the string has many repeats, what is the maximum number of unique substrings? 3. Extend: return each unique substring along with its frequency (count of occurrences). 4. How does a suffix array solve this problem and what is its time complexity?

## Problem In an array of n integers from 1 to n with one duplicate and one missing, find both the duplicate and the missing number. ## Likely LeetCode equivalent LC 645 - Set Mismatch (>80% confident) ## Tags arrays, math, hash_table

## Problem Compute the nth Fibonacci number using recursion, memoization, or iterative DP. ## Likely LeetCode equivalent LC 509 - Fibonacci Number (>80% confident) ## Tags recursion, dynamic_programming, math

## Problem Merge or correct overlapping text edits or corrections in a document, handling conflicting spans of text changes. ## Likely LeetCode equivalent No direct unambiguous LC equivalent. ## Tags strings, sorting, intervals

## Problem Given a list of time points in HH:MM format, find the minimum difference in minutes between any two time points. ## Likely LeetCode equivalent LC 539 - Minimum Time Difference (>80% confident) ## Tags math, sorting, strings

## Problem Given a list of integers and a reduction rule, repeatedly apply the rule until only one element remains. Return that element. **Rule:** In each pass, scan left to right. Remove any element that is smaller than its right neighbor. If no element is removed in a pass, stop. Return the last remaining element. ```python def reduce_list(nums: List[int]) -> int: ... ``` **Example:** ``` Input: [3, 1, 4, 1, 5, 9, 2, 6] Pass 1: remove 3 (3<4)? No, 3>1. Remove 1 (1<4) -> [3,4,1,5,9,2,6] remove 1 (1<5) -> [3,4,5,9,2,6] remove 2 (2<6) -> [3,4,5,9,6] Pass 2: no element < right neighbor that qualifies -> stops at [3,4,5,9,6] # Note: clarify exact rule with interviewer. Simpler variant: nums=[5,3,1], remove smallest each pass [5,3,1] -> remove 1 -> [5,3] -> remove 3 -> [5] -> output 5 ``` ## Follow-ups 1. Prove the invariant: what property does the remaining list always satisfy after each pass? 2. What is the worst-case number of passes for a list of length n? 3. How does the answer change if you remove elements larger than their right neighbor instead? 4. How would you parallelize the reduction using a segment tree?

## Problem Remove adjacent duplicate characters from a string repeatedly until no adjacent duplicates remain, using a stack. ## Likely LeetCode equivalent LC 1047 - Remove All Adjacent Duplicates In String (>80% confident) ## Tags stack, strings

## Problem Review the following Java code for a thread-safe counter. Identify all bugs, concurrency issues, and code quality problems. For each issue, explain the fix. ```java public class SharedCounter { private int count = 0; private List<Integer> history = new ArrayList<>(); public void increment() { count++; // (1) history.add(count); // (2) } public int getCount() { return count; // (3) } public List<Integer> getHistory() { return history; // (4) } public void reset() { count = 0; history.clear(); // (5) } } ``` **Issues to find:** - (1) Non-atomic read-modify-write on `count`. - (2) `ArrayList` is not thread-safe; concurrent adds cause data corruption. - (3) Stale read - no visibility guarantee without `volatile` or lock. - (4) Returning mutable reference leaks internal state. - (5) Non-atomic compound reset allows torn reads between `count=0` and `history.clear()`. ## Follow-ups 1. Rewrite using `AtomicInteger` and `CopyOnWriteArrayList`. What are the tradeoffs? 2. When would you use `synchronized` vs `ReentrantLock` vs `AtomicInteger`? 3. How would you write a unit test that reliably exposes the race condition in the original code? 4. Describe a scenario where `CopyOnWriteArrayList` performs poorly.

See All 24 Grammarly Software Engineer Questions

Full question text, answer context, and frequency data for subscribers.

Get Access