Refresh to get another 5 random questions

Find the missing numbers

Given an array of size n. It contains numbers in the range 1 to n. Each
number is present at least once except for 2 numbers. Find the missing

Warden and prisoners

The warden meets with 23 new prisoners when they arrive. He tells them, "You
may meet today and plan a strategy. But after today, you will be in isolated
cells ...

Tags: puzzle

The median of waiting time

Let r be a fixed positive integer, and let W be the waiting time until the r-th head in a sequence of fair coin tosses. Find a simple formula in ...

Stack Permutations

(1) Write a program to find all possible permutations that can be generated from 1,2,...,n through a stack.

(2) Given a sequence of 1,2,...,n that was generated from an ...

Find the max window of matching patterns.

Given two sequences of length N, how to find the max window of matching patterns. The patterns can be mutated.

For example, seq1 = "ABCDEFG", seq2 = "DBCAPFG", then ...