CodeSignal logo

CodeSignal

San Francisco, CASoftware

Interview Questions

Array Mutation Challenge

Asked at CodeSignal
technical
arrays
implementation

Given array a[n], create array b where b[i] = a[i-1] + a[i] + a[i+1]. Treat out-of-bounds as 0.

Example: Input: n = 5, a = [4, 0, 1, -2, 3] Output: [4, 5, -1, 2, 1]

Explanation:

  • b[0] = 0 + 4 + 0 = 4
  • b[1] = 4 + 0 + 1 = 5
  • b[2] = 0 + 1 + (-2) = -1
  • b[3] = 1 + (-2) + 3 = 2
  • b[4] = (-2) + 3 + 0 = 1

Character Cascade Builder

Asked at CodeSignal
technical
strings
arrays

Build a string by taking characters column-wise from an array of strings.

Example: Input: ["Daisy", "Rose", "Hyacinth", "Poppy"] Output: "DRHPaoyoisapsecpyiynth"

Rules:

  • Start with 0th character of each word
  • Then take 1st character of each word
  • Skip words that don't have current index
  • Continue until all characters are used

Card Hand Validation

Asked at CodeSignal
technical
arrays
validation

You are provided with a set of cards characterized by suits (+, -, =), values (A, B, C), and counts of these values ranging from 1 to 3. Your task is to identify a valid hand from the given cards. A valid hand consists of 3 cards where:

  • All the suits are either the same or all different,
  • All the values are either the same or all different,
  • All the counts are either the same or all different.

Example 1: Input cards: { +AA, -AA, +AA, -C, -B, +AA, -AAA, -A, =AA }

Valid hands could be:

{ +AA, +AA, +AA }
Suit: Same [+ + +]
Value: Same [A A A]
Count: Same [2 2 2]

{ -A, -AA, -AAA }
Suit: Same [- - -]
Value: Same [A A A]
Count: Different [1 2 3]

Example 2: A valid hand can also be:

{ -A, +BB, =CCC }
Suit: Different [+, -, =]
Value: Different [A B C]
Count: Different [1 2 3]

Count Valid Words from String

Asked at CodeSignal
technical
strings
validation

Given a string and a list of valid letters, count how many words in the string can be formed using the letters in the valid letters list.

Requirements:

  • Words are split using spaces
  • Punctuation and numbers are always valid
  • Case-sensitive for letters not in valid list

Example:

Input:
String: "Hello, I am h2ere!"
Letters: "heloiar"

Output: 3

Explanation:
Valid words: "Hello,", "I", "h2ere!"
Invalid word: "am" (as 'm' is not in valid letters)

Game Field Matrix Puzzle

Asked at CodeSignal
technical
matrix
algorithms

Given a matrix of integers field (n × m) and a figure matrix (3 × 3), find valid dropping positions.

Requirements:

  • Matrices contain only 0s (free) and 1s (occupied)
  • Figure drops straight down until bottom or collision
  • Goal: Form at least one fully occupied row
  • Figure must stay within field bounds

Example:

Field:
[[0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0],
 [1, 1, 0, 1, 0],
 [1, 0, 1, 0, 1]]

Figure:
[[1, 1, 1],
 [1, 0, 1],
 [1, 0, 1]]

Output: 2

Constraints:

  • 4 ≤ field.length ≤ 100
  • 3 ≤ field[i].length ≤ 100
  • Figure's occupied cells must be connected
  • At least one occupied cell in figure's bottom row

Memory Allocation System

Asked at CodeSignal
technical
bit manipulation
memory management

Implement a memory allocation system using bit arrays.

Memory Structure:

  • Array of 0s and 1s
  • Every 8 bits is one block
  • Contiguous 0s at block start = free memory

Query Types:

  1. Allocate Memory (i = 0):
Input: (0, 5)
Action: Find earliest block with 5 consecutive 0s at start
Return: Starting index or -1
Mark allocated bits as 1
  1. Release Memory (i = 1):
Input: (1, 3)
Action: Release 3rd successful allocation
Return: Size of released memory
Mark bits as 0

Example: Block: [00111111][11111100] Free memory sizes: 2, 0

Phone Number to Words Converter

Asked at CodeSignal
technical
strings
recursion

Convert phone numbers to possible valid words using phone keypad mapping.

Keypad Mapping:

2: 'abc'
3: 'def'
4: 'ghi'
5: 'jkl'
6: 'mno'
7: 'pqrs'
8: 'tuv'
9: 'wxyz'

Requirements:

  • Variable length phone numbers
  • Return all valid dictionary words
  • Case-sensitive matching

Example:

Input: '76278'
Output: ['roast', 'smart', 'snast']

Assumptions:

  • Dictionary available via load_dict()
  • Dictionary returns list of valid words

Worker Hours Registration System

Asked at CodeSignal
technical
system design
time tracking

Implement a system to track contract worker hours and compensation.

Level 1: Basic Operations

ADD_WORKER <workerId> <position> <compensation>
REGISTER <workerId> <timestamp>
GET <workerId>

Level 2: Statistics

  • Track time spent in office

Level 3: Worker Management

  • Support promotions
  • New positions/compensation
  • Salary calculations

Level 4: Special Time Periods

  • Support double-paid periods

Example:

Input:
["ADD_WORKER", "john", "engineer", "100"]
["REGISTER", "john", "1000"]
["REGISTER", "john", "1015"]

Output:
["true", "registered", "registered", "15"]

Requirements:

  • Handle invalid requests
  • Track entry/exit times
  • Calculate work duration
  • Support compensation changes

CodeSignal Question 1

Asked at CodeSignal
technical
system design
algorithms
CodeSignal Question 1

CodeSignal Question 2

Asked at CodeSignal
technical
system design
algorithms
CodeSignal Question 2

Share Your Experience at CodeSignal