emu in blogjava

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            171 隨筆 :: 103 文章 :: 1052 評論 :: 2 Trackbacks
          DiskClusters
          Problem Statement

          You are given a String disk representing the clusters on a disk. An 'X' represents a used cluster,
          and a '.' represents an available cluster. You are also given an int size representing the size, 
          in clusters, of a file waiting to be written to disk. A file can only be stored in clusters not already being used.
          Return the minimum number of groups of consecutive clusters needed to store the file on the disk.
          (The disk does not wrap around at the end.) Return -1 if the disk does not have enough space available
          to store the file.
          Definition

          Class:
          DiskClusters
          Method:
          minimumFragmentation
          Parameters:
          String, int
          Returns:
          int
          Method signature:
          int minimumFragmentation(String disk, int size)
          (be sure your method is public)


          Constraints
          -
          disk will contain between 1 and 50 characters, inclusive.
          -
          Each character of disk will be 'X' or '.'.
          -
          size will be between 1 and 50, inclusive.
          Examples
          0)


          "."
          2
          Returns: -1
          We can't fit the file on the disk.
          1)


          ".XXXXXXXX.XXXXXX.XX.X.X."
          6
          Returns: 6
          There is only ever one cluster together, so all six clusters are separated.
          2)


          "XX..XX....X.XX........X...X.XX...XXXX..XX...XXXXX."
          12
          Returns: 2
          We fit eight clusters together, and four clusters together.
          3)


          ".X.XXXX.......XX....X.....X............XX.X.....X."
          20
          Returns: 3

          4)


          "....X...X..X"
          11
          Returns: -1

          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-13 13:33 emu 閱讀(939) 評論(0)  編輯  收藏 所屬分類: google編程大賽模擬題及入圍賽真題
          主站蜘蛛池模板: 蒲城县| 沂水县| 三门峡市| 万宁市| 建阳市| 漠河县| 山丹县| 宁武县| 合阳县| 泽普县| 尚志市| 蕲春县| 津市市| 屯昌县| 遂宁市| 剑阁县| 高要市| 中方县| 宝兴县| 丘北县| 永嘉县| 通化市| 运城市| 洛浦县| 留坝县| 永修县| 逊克县| 建水县| 东辽县| 道孚县| 灌云县| 巴塘县| 汾阳市| 济阳县| 瓮安县| 民丰县| 乌鲁木齐市| 宁乡县| 屯昌县| 韶山市| 雅安市|