Interview in a few hours?

Brush up before you log in.

Fast recall cards, focused search, and just enough detail to refresh the right answers before the interview starts.

Clear

Results update as you type. Press / to jump straight into search.

All revision cards

49 cards

Coding Exercises Easy O(n)

Reverse String

Use slicing with a step of -1 for the shortest solution, or iterate from the end if the interviewer wants the mechanics.

Write a function that returns the input string reversed.

Coding Exercises Easy O(n)

Rotate Array

Normalize k by array length, then rebuild the order from the tail slice followed by the front slice.

Rotate an array to the right by k positions.

Coding Exercises Easy O(n)

Two Sum

Store each seen number in a dictionary keyed by value. For each new number, check whether target minus number has already appeared.

Return the indices of two numbers that add up to a target.

Coding Exercises Easy O(n)

Two Sum II (Sorted Array)

Start with one pointer at the left and one at the right. Move the left pointer rightward when the sum is too small and the right pointer leftward when the sum is too large.

Given a sorted array, return the indices of two numbers that add up to a target.

Coding Exercises Easy O(n)

Valid Parentheses

Push opening brackets onto a stack and pop when you see a matching closer. Any mismatch or leftover opening bracket means the string is invalid.

Check whether brackets in a string are balanced and properly nested.