emu in blogjava

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            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 閱讀(1447) 評論(0)  編輯  收藏 所屬分類: google編程大賽模擬題及入圍賽真題
          主站蜘蛛池模板: 浠水县| 洪江市| 贵港市| 聂拉木县| 庄河市| 阿尔山市| 从江县| 若羌县| 灵宝市| 荔浦县| 合作市| 张北县| 奉新县| 禹城市| 遂平县| 宜章县| 武汉市| 蚌埠市| 辽阳市| 大厂| 德格县| 开江县| 宝丰县| 浮山县| 吴旗县| 缙云县| 和林格尔县| 巴马| 渝北区| 灵丘县| 驻马店市| 房产| 靖江市| 河池市| 陇南市| 灌云县| 罗田县| 霞浦县| 永安市| 无为县| 江陵县|