SoFi logo

SoFi

San Francisco, CAFintech

Interview Questions

Anagram Search

Asked at SoFi
technical
strings
algorithms

Find all anagrams of a search word in a list.

Function:

function findAnagrams(words: string[], searchWord: string): string[]

Example: words = ["enlist", "google", "inlets", "banana"] searchWord = "listen" Output: ["enlist", "inlets"]

Strategy:

  • Sort characters for comparison
  • Handle case sensitivity
  • Optimize for large word lists

Asteroids Collision

Asked at SoFi
technical
arrays
stack

Determine final state after asteroid collisions.

Function:

function asteroidCollision(asteroids: number[]): number[]

Examples:

  1. [5, 10] → [5, 10]
  2. [8, -8] → []
  3. [2, -5, 10] → [10]

Requirements:

  • Handle positive/negative directions
  • Process collisions in order
  • Return final state

Binary Search Tree Operations

Asked at SoFi
technical
trees
data structures

Implement core BST operations and validation.

  1. Insert Node
interface TreeNode {
  val: number;
  left: TreeNode | null;
  right: TreeNode | null;
}

function insert(root: TreeNode | null, val: number): TreeNode
  1. Validate BST
function isValidBST(root: TreeNode | null): boolean

Requirements:
- Left subtree values < node value
- Right subtree values > node value
- Handle duplicates
- Consider min/max constraints

Content Moderation System

Asked at SoFi
technical
system design
content moderation

Design a system to detect blocking words in reviews.

Requirements:

  • Handle multiple platforms (Google, Yelp, Facebook)
  • Support blocking word patterns
  • Real-time moderation
  • Scalable solution

Implementation:

  • Pattern matching algorithms
  • Efficient word lookup
  • Handle case sensitivity
  • Support multiple languages

Character Replacement Problem

Asked at SoFi
technical
strings
sliding window

Find longest substring with same characters after k replacements.

function longestSubstring(s: string, k: number): number

Example:
Input: s = "AABABBA", k = 1
Output: 4
Explanation: Replace one 'B' to get "AAABBA"

Requirements:

  • Handle k replacements
  • Track character frequencies
  • Sliding window approach
  • Optimize for space/time

Minimum Difference Pairs

Asked at SoFi
technical
arrays
algorithms

Find all pairs with minimum difference in array.

function findMinDiffPairs(arr: number[]): [number, number][]

Example:
Input: [1, 5, 3, 19, 18, 25]
Output: [[18, 19]]

Requirements:
- Return all pairs with min difference
- Handle duplicates
- Sort for optimization

Domain Rate Limiter

Asked at SoFi
technical
system design
rate limiting

Implement a rate limiter for domain names.

Requirements:

class DomainRateLimiter {
  constructor(limit: number, windowSeconds: number)
  allowRequest(domain: string): boolean
}

Example:
1. a.com → pass
2. b.com → pass
3. a.com → pass
4. a.com → pass
5. a.com → drop (exceeded limit)
6. a.com → pass (after window)

Implementation:

  • Sliding window tracking
  • Per-domain limits
  • Thread-safe operations
  • Memory efficient

Reverse Linked List

Asked at SoFi
technical
linked list
algorithms

Reverse a singly linked list.

interface ListNode {
  val: number;
  next: ListNode | null;
}

function reverseList(head: ListNode | null): ListNode | null

Constraints:
- 0 <= nodes <= 5000
- -5000 <= Node.val <= 5000

Example:
Input: [1,2,3,4,5]
Output: [5,4,3,2,1]

Second Largest Element

Asked at SoFi
technical
arrays
algorithms

Find second largest distinct element in array.

function findSecondLargest(arr: number[]): number

Examples:
1. [35, 34, 23, 12] → 34
2. [10, 5, 10] → 5
3. [10, 10, 10] → -1 (no second largest)

Requirements:
- Handle duplicates
- Return -1 if no second largest
- Single pass solution preferred

Shortest Distinct Substring

Asked at SoFi
technical
strings
sliding window

Find shortest substring containing all distinct characters.

function shortestDistinctSubstring(s: string): string

Example:
Input: "aabcbcdbca"
Output: "dbca"

Requirements:
- Include all distinct chars
- Minimize length
- Handle duplicates
- Optimize runtime

Word Ladder

Asked at SoFi
technical
graphs
bfs

Find shortest transformation sequence between words.

function ladderLength(
  beginWord: string,
  endWord: string,
  wordList: string[]
): number

Examples:
1. beginWord = "hit"
   endWord = "cog"
   wordList = ["hot","dot","dog","lot","log","cog"]
   Output: 5 (hit→hot→dot→dog→cog)

2. endWord not in wordList
   Output: 0

Constraints:
- 1 <= word.length <= 10
- All lowercase letters
- All words same length
- Unique words in wordList

Share Your Experience at SoFi