文章列表
Problem Statement
A simple way to compress a string is to encode repeated consecutive substrings as a counter followed by the substring. For example, if X represents a substring, and the string contains a sequence "XX...X", we can compress the sequence as "[DX]&qu ...
TCHS-9-250
- 博客分类:
- TopCoder
Problem Statement
One day, nClassmates classmates decided to play an exciting game. They formed a circle and assigned themselves player numbers from 0 to nClassmates - 1 in a clockwise direction. Then, they counted from 1 to nTimes, inclusive, starting with player 0 and going i ...
Problem Statement
When scheduling tasks to be executed by a person, it is sometimes the case that when one task is completed, a later task suddenly becomes more important. In these situations, it is said that the later task is a 'Supertask' of the completed one.In addition, when a ...
Problem Statement
A common task for math students is to solve 'word math' questions, where each distinct letter represents a distinct digit.Given a list of word math numbers to add, your task is to calculate the greatest possible sum of those numbers.For example, given the expr ...
Problem Statement
Last night, after that terrible nightmare about pink elephants, you decided that you would never again go to sleep unless the time showing on your digital clock was a multiple of the number of elephants in your dream. Rather than waiting and constantly checking th ...
Problem Statement
You are given an even number of points in the plane. You want to find a rectangle whose corners have integer coordinates and sides are parallel to the axes, such that at least half of the given points lie in the interior of the rectangle. Return the area of the ...
Problem Statement
An array of ints is said to be a straight if it contains five elements that are five consecutive numbers. For example, the array { 6, 1, 9, 5, 7, 15, 8 } is a straight because it contains 5, 6, 7, 8, and 9.
Given an array of ints, nums, return the minimum ...
TCHS-7-250
- 博客分类:
- TopCoder
Problem Statement
You are given a String text. Determine the letters (both lowercase and uppercase) that appear in text. Return a String which contains those letters, converted to lowercase, and then sorted in alphabetical order. The returned String should include all occurrences o ...
Problem Statement
We are given a maze which is a cube of NxNxN cells. We start at (1,1,1) and we move to (N,N,N), in each move visiting one of the three adjacents cells in the positive x, y or z directions. Each cell of the maze contains either a '(', ')' or '.'. A path is the se ...
Problem Statement
You have just hacked into your friend's computer, and you want to delete one of his personal files. But wait, why not let him delete it! As you keep watching him, he has a delete command typed in on the terminal which contains a pattern. You want to rename the f ...
Problem Statement
A digital clock displays time in the format "DD:DD:DD" (quotes for clarity only), where each D is a single digit, and each pair of contiguous digits represents either the hour, minute, or second (each of these three units will occur exactly once). Unfort ...
Problem Statement
When programming, I don't like to take my fingers off the keyboard, and hence, I don't use the mouse. So, when navigating my source, I like to do so in such a way as to minimize keystrokes. My text editor supports the following keystrokes: left, right, up, down, h ...
Problem Statement
A sentence is composed of words, spaces and punctuation. For this problem, words are maximal contiguous strings of letters. Given a sentence, sort the words in the sentence while preserving the spaces and punctuation. Sorting is case sensitive, so uppercase letter ...
TCHS-5-250
- 博客分类:
- TopCoder
Problem Statement
When shopping for TVs consumers may notice that a TV's size is given by its diagonal in inches. The aspect ratio of a screen is the ratio of its width to its height. Given the aspect ratio and the diagonal size in inches of a TV screen, you must compute its width ...
Problem Statement
Masterbrain is a two player board game in which one player decides on a secret combination of digits, while the other must figure it out in 10 guesses or less. The game differs from Mastermind in that the player making the secret combination is allowed to lie on ...