Attention candidates preparing for TikTok, Google, Amazon and other major tech company OAs! This CodeSignal question set covers 4 classic problem types, from string processing to graph simulation, with increasing difficulty.
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.
✅ Question 1: Count Substrings With Vowels
Problem Description
You are developing an automatic moderation system for a chat application that detects certain linguistic patterns.
Given a string chatMessage, count the number of substrings of exactly length 3 where at least one character is a vowel ("a", "e", "i", "o", "u", or their uppercase counterparts).
Constraints: 1 ≤ chatMessage.length ≤ 1000
Examples
Input: chatMessage = "CodeSignal"
Output: 8
Explanation: Substrings of length 3: "Cod", "ode", "deS", "eSi", "Sig", "ign", "gna", "nal"
All contain at least one vowel → 8 substrings
Input: chatMessage = "StrEngThen"
Output: 5
Explanation: Substrings with vowels: "trE", "rEn", "Eng", "The", "hen" → 5 substrings
oavoservice Perfect Solution
def solution(chatMessage):
vowels = set('aeiouAEIOU')
count = 0
for i in range(len(chatMessage) - 2):
substring = chatMessage[i:i+3]
if any(c in vowels for c in substring):
count += 1
return count
Time Complexity: O(n), single pass solution
✅ Question 2: Consonant Cipher Shift
Problem Description
You're implementing a simple substitution cipher that only affects consonant characters in a memo.
This cipher works by shifting every k-th consonant to the following consonant in the alphabet, while leaving vowels and other characters unchanged.
Rules:
- Only consonant characters are affected: 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'
- When shifting from 'z', it wraps around to 'b'
- The case of each character must be preserved
Example
Input: memo = "CodeSignal", k = 3
Output: "CodeTignam"
Explanation:
Consonants: 'C', 'd', 'S', 'g', 'n', 'l'
3rd consonant 'S' → 'T'
6th consonant 'l' → 'm'
oavoservice Perfect Solution
def solution(memo, k):
consonants = 'bcdfghjklmnpqrstvwxyz'
consonant_set = set(consonants + consonants.upper())
def next_consonant(c):
lower = c.lower()
idx = consonants.index(lower)
next_c = consonants[(idx + 1) % len(consonants)]
return next_c.upper() if c.isupper() else next_c
result = list(memo)
consonant_count = 0
for i, c in enumerate(memo):
if c in consonant_set:
consonant_count += 1
if consonant_count % k == 0:
result[i] = next_consonant(c)
return ''.join(result)
Key Point: Consonant counter + modulo operation to identify every k-th consonant
✅ Question 3: Molecular Bond Pairing
Problem Description
You are a chemist working in a laboratory that studies molecular compounds. You have two arrays representing the atomic weights of elements in two different compounds:
xrepresents the primary elementsyrepresents the secondary elements
Two compounds with the same balance factor (difference between primary and secondary atomic weights) can form stable bonds.
Task: Count the number of unique molecular pairings (i, j) where i < j and x[i] - y[i] == x[j] - y[j].
Example
Input: x = [2, -2, 5, 3], y = [1, 5, -1, 1]
Output: 6
Explanation:
Compute all x[i] - y[i]: → 1, -7, 6, 2
Count pairs with same difference value
oavoservice Perfect Solution
from collections import defaultdict
def solution(x, y):
diff_count = defaultdict(int)
count = 0
for i in range(len(x)):
diff = x[i] - y[i]
count += diff_count[diff]
diff_count[diff] += 1
return count
Time Complexity: O(n), single pass with HashMap
Core Idea: Classic Two Sum variant using HashMap to store difference frequencies
✅ Question 4: Teleport Labyrinth
Problem Description
Imagine you're exploring a mysterious labyrinth in the shape of a rectangular matrix, which contains obstacles and teleports. Your goal is to reach the lower-right corner by only moving to the right starting from the upper-left corner.
Input:
- Integers n and m: dimensions of the labyrinth
- obstacles: cells that cannot be passed
- teleports: list of [start_row, start_col, end_row, end_col] for one-way teleportation
Movement Rules:
- You always move to the right (from [row, col] to [row, col + 1])
- If you reach a cell that is a teleport start, you are moved instantly to its end cell
- Obstacles block movement completely
- You stop if you move outside bounds or hit an obstacle
Output:
- Return the number of cells traversed, including start and teleport endpoints
- Return -1 if blocked by obstacle or out of bounds
- Return -2 if stuck in infinite teleport loop
- Return -3 if unable to reach goal but not due to obstacle or teleport loop
Example
Input: n = 3, m = 3, obstacles = [[2, 1]], teleports = [[0, 1, 2, 0]]
Grid:
[0,0] [0,1]*T [0,2]
[1,0] [1,1] [1,2]
[2,0] [2,1]X [2,2]
You start at [0,0], move to [0,1] → teleport to [2,0]
Cannot move right to [2,1] because it's an obstacle
→ Return -1
oavoservice Perfect Solution
def solution(n, m, obstacles, teleports):
obstacle_set = set(tuple(o) for o in obstacles)
teleport_map = {(t[0], t[1]): (t[2], t[3]) for t in teleports}
row, col = 0, 0
visited = set()
cells_traversed = 0
while True:
# Check for teleport loop
state = (row, col)
if state in visited:
return -2
visited.add(state)
# Check for obstacle
if (row, col) in obstacle_set:
return -1
cells_traversed += 1
# Check if reached destination
if row == n - 1 and col == m - 1:
return cells_traversed
# Check for teleport
if (row, col) in teleport_map:
row, col = teleport_map[(row, col)]
continue
# Move right
col += 1
# Check bounds
if col >= m:
return -3
# Check obstacle
if (row, col) in obstacle_set:
return -1
return -3
Core Focus: State machine simulation + cycle detection + multiple termination conditions
💡 Why Do These Problems Filter Out So Many Candidates?
These 4 problems may seem independent, but they test the core competencies in OA assessments:
- String Processing Basics - Q1 tests sliding window thinking
- Simulation & State Tracking - Q2 tests counters and character mapping
- HashMap Optimization - Q3 is a classic Two Sum variant
- Graph Theory & State Machines - Q4 tests complex condition simulation
🚀 oavoservice: Your Perfect Score Guarantee
We consistently provide professional online assessment services for major tech companies like TikTok, Google, Amazon, Microsoft, Meta, guaranteeing perfect scores.
✅ Full Coverage: Familiar with CodeSignal, HackerRank, Karat, and all major OA platforms
✅ Real-time Response: 24/7 online support, always ready
✅ Perfect Score Guarantee: Professional algorithm team, 100% pass rate
✅ Safe & Reliable: Years of experience, never failed
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.
📩 Contact us anytime for assistance.
👉 Add WeChat: Coding0201
Secure your Big Tech Offer today!