Statistics

Problem Statement for "BigCube"

Problem Statement

This problem contains HTML superscripts which may not display properly for plugin users. Please use the applet to view the problem statement and examples

You are given a list of integer intervals, ranges, where each interval is specified by a String of the form "<low>-<high>" (quotes for clarity). Here "<low>" and "<high>" represent non-negative integers (sequences of characters between '0' and '9' inclusive with no leading zeros) which are separated by a single hyphen '-'.

Your task is to find the largest integer that is in at least one of the intervals and is a perfect cube. Return this integer in a String with no extra leading zeros and only the digits '0'-'9'. In other words, find the largest integer in the intervals that is equal to n3 for some integer n. If there is no perfect cube in the intervals, return the empty string, "" (quotes for clarity).

For example {"1-1000000000001"} would return "1000000000000" which is 100003.

Definition

Class:
BigCube
Method:
largestCube
Parameters:
String[]
Returns:
String
Method signature:
String largestCube(String[] range)
(be sure your method is public)

Notes

  • C++ users: the 64 bit integer type is long long.

Constraints

  • range will have between 1 and 50 elements inclusive.
  • Each element of range will contain between 3 and 31 characters inclusive.
  • Each element of range will be of the form "-" where and are separated by exactly one hyphen, '-'.
  • Each character of and will be a digit between '0' and '9' inclusive.
  • and will contain no leading zeros.
  • and will be between 0 and 1000000000000000 (1e15) inclusive.
  • will be less than or equal to

Examples

  1. {"1-1000000000001"}

    Returns: "1000000000000"

    The example from above: 100003

  2. {"10-999999999999990","11-999999999999991","12-999999999999992", "13-999999999999993","14-999999999999994","15-999999999999995", "16-999999999999996","17-999999999999993","18-999999999999994", "19-999999999999999"}

    Returns: "999970000299999"

    999993

  3. {"0-3","10-20","30-60","80-120"}

    Returns: "1"

  4. {"0-0","2-7","9-26","28-63","65-124"}

    Returns: "0"

  5. {"999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972"}

    Returns: ""

  6. {"0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000", "0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000", "0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000", "0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000", "0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000", "0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000", "0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000", "0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000", "0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000", "0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000","0-1000000000000" }

    Returns: "1000000000000"

  7. {"1-999999999999","1-999999999999","1-999999999999","1-999999999999","1-999999999999", "1-999999999999","1-999999999999","1-999999999999","1-999999999999","1-999999999999", "1-999999999999","1-999999999999","1-999999999999","1-999999999999","1-999999999999", "1-999999999999","1-999999999999","1-999999999999","1-999999999999","1-999999999999", "1-999999999999","1-999999999999","1-999999999999","1-999999999999","1-999999999999", "1-999999999999","1-999999999999","1-999999999999","1-999999999999","1-999999999999", "1-999999999999","1-999999999999","1-999999999999","1-999999999999","1-999999999999", "1-999999999999","1-999999999999","1-999999999999","1-999999999999","1-999999999999", "1-999999999999","1-999999999999","1-999999999999","1-999999999999","1-999999999999", "1-999999999999","1-999999999999","1-999999999999","1-999999999999","1-999999999999" }

    Returns: "999700029999"

  8. {"999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "1000001-1000000000" }

    Returns: "1000000000"

  9. {"999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "999700030000-999999999999","999400119993-999700029998", "999100269974-999400119991","998800479937-999100269972", "0-0" }

    Returns: "0"

  10. {"999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999", "999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999", "999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999", "999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999", "999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999", "999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999", "999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999", "999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999", "999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999", "999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999","999970000300000-999999999999999" }

    Returns: ""

  11. {"0-0","2-2","3-3","4-4","5-5","6-6","7-7","9-9","10-10","12-12", "14-14","16-16","18-18","20-20","22-22","24-24","26-26","28-28", "30-30","32-32","34-34","36-36","38-38","40-40","42-42","44-44", "46-46","48-48","50-50","52-52","54-54","56-56","58-58","60-60", "62-62","65-65","67-67","69-69","71-71","73-73","75-75","77-77", "79-79","81-81","83-83","85-85","87-87","89-89","99-99", "999970000300000-999999999999999" }

    Returns: "0"

  12. {"1-8"}

    Returns: "8"

  13. {"2-26"}

    Returns: "8"

  14. {"2-63"}

    Returns: "27"

  15. {"1-2197"}

    Returns: "2197"

  16. {"125000000000000-125000000000000"}

    Returns: "125000000000000"

  17. {"1881365963625-1881365963625"}

    Returns: "1881365963625"

  18. {"123456789012345-234567890123456"}

    Returns: "234565479336448"

  19. {"100-100","2-2","3-3","4-4","5-5","6-6","7-7","9-9","10-10","12-12", "14-14","16-16","18-18","20-20","22-22","24-24","26-26","28-28", "30-30","32-32","34-34","36-36","38-38","40-40","42-42","44-44", "46-46","48-48","50-50","52-52","54-54","56-56","58-58","60-60", "62-62","65-65","67-67","69-69","71-71","73-73","75-75","77-77", "79-79","81-81","83-83","85-85","87-87","89-89","99-99", "999970000300000-999999999999999" }

    Returns: ""

  20. {"1000000000001-1000333333333"}

    Returns: "1000300030001"

  21. { "1-1000000000001" }

    Returns: "1000000000000"

  22. { "1-1" }

    Returns: "1"

  23. { "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000", "1-1000000000000000" }

    Returns: "1000000000000000"

  24. { "1-1000000000000000" }

    Returns: "1000000000000000"

  25. { "2-4", "120-130" }

    Returns: "125"

  26. { "0-1001", "2-2", "3-3", "4-4", "5-5", "6-6", "7-7", "9-9", "10-10", "12-12", "14-14", "16-16", "18-18", "20-20", "22-22", "24-24", "26-26", "28-28", "30-30", "32-32", "34-34", "36-36", "38-38", "40-40", "42-42", "44-44", "46-46", "48-48", "50-50", "52-52", "54-54", "56-56", "58-58", "60-60", "62-62", "65-65", "67-67", "69-69", "71-71", "73-73", "75-75", "77-77", "79-79", "81-81", "83-83", "85-85", "87-87", "89-89", "99-99", "1-999999999999999" }

    Returns: "999970000299999"

  27. { "99994258523375-99994258523375" }

    Returns: "99994258523375"

  28. { "8-10" }

    Returns: "8"

  29. { "0-0", "2-2", "3-3", "4-4", "5-5", "6-6", "7-7", "9-9", "10-10", "12-12", "14-14", "16-16", "18-18", "20-20", "22-22", "24-24", "26-26", "28-28", "30-30", "32-32", "34-34", "36-36", "38-38", "40-40", "42-42", "44-44", "46-46", "48-48", "50-50", "52-52", "54-54", "56-56", "58-58", "60-60", "62-62", "65-65", "67-67", "69-69", "71-71", "73-73", "75-75", "77-77", "79-79", "81-81", "83-83", "85-85", "87-87", "89-89", "99-99", "999970000300000-999999999999999" }

    Returns: "0"

  30. { "63-100", "998-1001", "1003-998988" }

    Returns: "970299"

  31. { "10-999999999999990", "11-999999999999991", "12-999999999999992", "13-999999999999993", "14-999999999999994", "15-999999999999995", "16-999999999999996", "17-999999999999993", "18-999999999999994", "19-999999999999999" }

    Returns: "999970000299999"

  32. { "3-8" }

    Returns: "8"

  33. { "1-10", "1-9872564", "23457-334676" }

    Returns: "9800344"

  34. { "1000000000000000-1000000000000000" }

    Returns: "1000000000000000"


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)2024, TopCoder, Inc. All rights reserved.
This problem was used for: