GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesWeather Detective

Gamified challenge · Hidden Markov models

Weather Detective

The weather on each day is a hidden state: 0 = S (sunny), 1 = R (rainy) and, when there are three states, 2 = C (cloudy). observations has one letter per day: U (umbrella) or N (no umbrella). Chances are given in whole tenths (7 means 0.7): start[s] for day 1, trans[a][b] for weather a followed by b, and emit[s][0] / emit[s][1] for an umbrella / no umbrella on an s day.

A weather sequence w scores start[w1]·emit[w1][o1] · trans[w1][w2]·emit[w2][o2] · …, an exact integer (at most 10^18 for the 9-day maximum: use long in Java). Write viterbi(observations, start, trans, emit) returning the highest-scoring sequence as a string such as "SSRR". Ties go to the earlier state on the last day, then on the day before, and so on (what Viterbi does when it keeps the first best predecessor and the first best final state). An empty diary gives "".

Example: observations = "UUNUN", start = [6, 4], trans = [[7, 3], [4, 6]], emit = [[1, 9], [8, 2]] gives "RRSRS".

Sign in to play Weather Detective

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account