emu in blogjava

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  171 随笔 :: 103 文章 :: 1052 评论 :: 2 Trackbacks

Problem Statement
????
You want to buy two neighboring tickets in the first row of the theater so that one of the tickets is as far from the aisles as possible.
You will be given a String describing the first row of the theater where '.' represents an empty seat and 'X' represents an occupied seat. Your task is to return the index (from 0) of the empty seat that is furthest from the aisles (the two ends of the String) and is also next to an empty seat. If there are multiple possible seats, return the one with the smallest index. Return -1 if there are no seats that satisfy your requirements.
Definition
????
Class:
TheaterVisit
Method:
chooseSeat
Parameters:
String
Returns:
int
Method signature:
int chooseSeat(String row)
(be sure your method is public)
????

Constraints
-
row will contain between 1 and 50 characters, inclusive.
-
Each character in row will be either '.' or 'X'.
Examples
0)

????
"....."
Returns: 2
You can buy either tickets with indexes 1 and 2 or tickets with indexes 2 and 3.
1)

????
"......"
Returns: 2

2)

????
"..X..."
Returns: 3
You should buy tickets with indexes 3 and 4.
3)

????
".X.X..."
Returns: 4

4)

????
"X.XX.X"
Returns: -1

5)

????
".."
Returns: 0

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.

posted on 2005-12-20 10:27 emu 阅读(1425) 评论(0)  编辑  收藏 所属分类: google编程大赛模拟题及入围赛真题

只有注册用户登录后才能发表评论。


网站导航: