ProblemDescriptionCategoryAction
Consider an algorithm that takes as input a positive integer n. If n is even, the algorithm divides it by two, and if n is odd, the algorithm multiplies it by three and adds one. The algorithm repeats this, until n is one. For example, the sequence for n = 3 is as follows: 3 → 10 → 5 → 16 → 8 → 4 → 2 → 1 Your task is to simulate the execution of the algorithm for a given value of n.
Introductory Problems
You are given all numbers between 1, 2, …, n except one. Your task is to find the missing number.
Introductory Problems
You are given a DNA sequence: a string consisting of characters A, C, G, and T. Your task is to find the longest repetition in the sequence. This is a maximum-length substring containing only one type of character.
Introductory Problems
You are given an array of n integers. You want to modify the array so that it is increasing, i.e., every element is at least as large as the previous element. On each move, you may increase the value of any element by one. What is the minimum number of moves required?
Introductory Problems
A permutation of integers 1, 2, …, n is called beautiful if there are no adjacent elements whose difference is 1. Given n, construct a beautiful permutation if such a permutation exists.
Introductory Problems
A number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral: Your task is to find out the number in row y and column x.
Introductory Problems
Your task is to count for k = 1, 2, …, n the number of ways two knights can be placed on a k × k chessboard so that they do not attack each other.
Introductory Problems
Your task is to divide the numbers 1, 2, …, n into two sets of equal sum.
Introductory Problems
Your task is to calculate the number of bit strings of length n. For example, if n = 3, the correct answer is 8, because the possible bit strings are 000, 001, 010, 011, 100, 101, 110, and 111.
Introductory Problems
Your task is to calculate the number of trailing zeros in the factorial n!. For example, 20! = 2432902008176640000 and it has 4 trailing zeros.
Introductory Problems
Page 1 of 30