Tags

State Machine

State Machine

0 lessons
4 problems
1 code snippet
2 question banks
3 community items

state-machine

Practice Problems

4 problems

Best Time to Buy and Sell Stock III

Not Started
Hard

Find the maximum profit from at most two stock transactions, where you must sell before buying again.

Dynamic Programming
State Machine
Arrays
Advanced

1.1k

26

Best Time to Buy and Sell Stock IV

Not Started
Hard

Find the maximum profit from at most k stock transactions, generalizing the Stock III problem to arbitrary k.

Dynamic Programming
State Machine
Arrays
Advanced

613

17

Best Time to Buy and Sell Stock with Cooldown

Not Started
Medium

Given an array of stock prices, find the maximum profit with unlimited transactions but a mandatory one-day cooldown after each sell.

Dynamic Programming
State Machine
Algorithms
Intermediate

997

8

String to Integer (atoi)

Not Started
Medium

Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer. Handle leading whitespace, optional sign, digit parsing, and integer overflow/underflow.

Strings
Mathematics
State Machine
Simulation
Algorithms
Intermediate

231

7

Code Snippets

1 snippet
Code Snippet
Premium

Generators as State Machines

Generators turn an explicit `switch (state)` block into a function whose own pause points encode the state. This snippet shows three flavors: a finite-state machine driven by `next(event)` for transitions, a step-by-step async sequencer that pauses between phases, and a richer machine with entry/exit side effects plus an unexpected-event handler. Reach for this when your control flow has a small, explicit set of states and you want the language to enforce them for you.

JavaScript
generators
state-machine
control-flow

1k

26

Hard

Question Banks

2 items
Question Bank
Premium

Interval and State-Machine DP

Interval DP (matrix chain, burst balloons shape) and state-machine DP (stock trading variants). Code stems are Python.

Python
interval-dp
state-machine
dynamic-programming
algorithms

892

6

Hard
Question Bank

React State Management Without Redux Quiz

Four checks on the non-Redux options for sharing React state: local component state, Context, useReducer, and lightweight stores like Zustand or Jotai.

JavaScript
quiz
react
hooks
state-machine

587

11

Easy