Statistics

Problem Statement for "MoneyRun"

Problem Statement

*** You may only submit a given problem once - no resubmissions will be accepted. ***

You have been given the opportunity of a lifetime. You and your friend get to run through a field full of money. Everything you and your friend pick up, you can keep. You will be given a String[] grid containing the locations of the prizes. Each character in grid will be a digit from 0-9 determining how much money is located in that particular location. The elements of grid will be the rows of the field. You and your friend will begin at row 0 column 0 of grid (element 0 character 0). Using only steps to the right and steps down, return the maximum amount of money both of you can collect. Here 'right' means increasing column value and 'down' means increasing row value. Note that you and your friend can take different routes. If you and your friend visit the same location, only one of you can pick up the money at that location. Both you and your friend will always end up on the lower rightmost location when you finish.

Definition

Class:
MoneyRun
Method:
getMost
Parameters:
String[]
Returns:
int
Method signature:
int getMost(String[] grid)
(be sure your method is public)

Constraints

  • grid will contain between 2 and 7 elements inclusive.
  • Each element of grid will contain between 2 and 7 characters inclusive.
  • Each element of grid will contain the same number of characters.
  • Each character in grid will be a digit ('0'-'9').

Examples

  1. { "111", "101", "111"}

    Returns: 8

    Let Y denote where you will pick up money, and H denote where he will. A possible solution is YYY H0Y HHH , since you are able to pick up all 8.

  2. { "99", "09" }

    Returns: 27

    Any way you try this, you can't get more than 27.

  3. { "09933", "29333", "03333", "41111"}

    Returns: 52

  4. {"11111", "22222"}

    Returns: 15

  5. { "99999", "99999", "99999", "99999", "99999"}

    Returns: 144

  6. {"5560000" ,"5050000" ,"5055550" ,"5565050" ,"0005055" ,"0005555"}

    Returns: 112

  7. {"9999999" ,"9999999" ,"9999999" ,"9999999" ,"9999999" ,"9999999" ,"9999999"}

    Returns: 216

  8. {"12" ,"12" ,"12" ,"12" ,"12" ,"12"}

    Returns: 18

  9. {"0022750","9528020","6357014","6965150","1145382","1349953","6275004"}

    Returns: 119

  10. {"8505451","8799547","5718722","7231299","1811971","8429026","9742736"}

    Returns: 147

  11. {"1948014","2512705","1993189","5479842","2143615","1307329","9895640"}

    Returns: 133

  12. {"7011163","3753176","9528628","3837661","4772024","4619467","3199992"}

    Returns: 143

  13. {"3984204","9480578","1170356","0421388","5457554","1669945","7426570"}

    Returns: 141

  14. {"9362886","6655168","6578458","0472608","3805095","9436826","4935140"}

    Returns: 136

  15. {"0204979","8575062","8353486","3930228","7586227","1255020","0089648"}

    Returns: 138

  16. {"2454067","0111892","4512460","4625668","3614435","8391430","9072341"}

    Returns: 108

  17. {"3137728","4000907","3857516","3140508","2757091","1397817","9478234"}

    Returns: 122

  18. {"1408629","1759791","3152853","1344463","3855562","9230238","1132352"}

    Returns: 116

  19. {"5602450","6790792","4887382","1238649","5762934","0456549","0490650"}

    Returns: 149

  20. {"7256408","1997151","2430268","2552971","4179799","7491235","8546307"}

    Returns: 132

  21. {"2404413","5355789","5277412","8250451","2346071","1535040","2543888"}

    Returns: 119

  22. {"0553187","8039571","7358900","0147020","6221306","4442568","5701961"}

    Returns: 116

  23. {"7014500","3513216","3025223","0768719","6649700","7301873","1855716"}

    Returns: 121

  24. {"9295379","8170081","8071427","0813148","7958086","5268411","9266644"}

    Returns: 141

  25. {"3607477","4996846","8843607","5837933","5261802","7280947","4762968"}

    Returns: 160

  26. {"8844228","3899633","9353008","2820845","4233116","9391557","1306387"}

    Returns: 145

  27. {"8329077","9829189","5380141","0776163","9572846","1998920","4353449"}

    Returns: 145

  28. {"8530054","4031778","5573198","3064407","1834946","5967351","0789764"}

    Returns: 137

  29. {"0517713","7658875","2321292","1225886","9840656","1498745","1237349"}

    Returns: 145

  30. {"7562083","7410851","7913661","2693334","4884696","9133404","0138780"}

    Returns: 138

  31. {"7991286","4712643","3710247","0274560","4516759","5744957","3182200"}

    Returns: 129

  32. {"6267870","7245916","2226593","3070451","5980549","8506124","6896300"}

    Returns: 131

  33. {"6617283","1711154","4443066","0214693","6099220","5161765","5230850"}

    Returns: 120

  34. {"1965576","8059295","8445114","7620807","8452256","9203732","6167071"}

    Returns: 134

  35. {"1250093","5100196","5532688","9989020","2053670","8222707","2687042"}

    Returns: 117

  36. {"8451597","1042834","1653116","5115535","1892491","3961429","3522793"}

    Returns: 120

  37. {"1580380","2157876","9110972","9218748","3667162","8474347","9104429"}

    Returns: 136

  38. {"6066678","8971407","4258018","9555640","6057158","3816478","3910828"}

    Returns: 147

  39. {"9955500" ,"5990500" ,"4499500" ,"0009900" ,"0000990" ,"0000599" ,"0000559"}

    Returns: 162

  40. {"9994444" ,"9999999" ,"2000009" ,"2000009" ,"2000009" ,"2000009" ,"9422119"}

    Returns: 153

  41. {"9994444" ,"9999999" ,"2000009" ,"2000009" ,"2000009" ,"2000009" ,"9122119"}

    Returns: 152

  42. {"9360090","9514088","5774209","8149091","6349424","8795771","4052419"}

    Returns: 146

  43. {"3054084","8262757","7802880","2126009","7406692","8475316","4445356"}

    Returns: 123

  44. {"0627809","1946552","4478381","2143357","0172937","1069132","7794500"}

    Returns: 118

  45. {"2335245","6577941","5248703","6179005","5946801","9489513","7467108"}

    Returns: 132

  46. {"7239416","7412814","9683074","8498365","2172691","2541993","5111055"}

    Returns: 144

  47. {"5684678","6823685","9273072","8076861","4289082","6160486","4553633"}

    Returns: 144

  48. {"8216906","1493752","0015496","8806247","2624564","5843907","4393653"}

    Returns: 132

  49. {"2854173","4593917","9425889","2720276","0327000","8043062","7022222"}

    Returns: 118

  50. {"0089109","0984048","7429746","7995332","5963057","6692443","5571571"}

    Returns: 127

  51. {"4154268","8445675","1046040","9507478","6482129","1012869","2170860"}

    Returns: 131

  52. {"9978281","9219267","8671259","3915767","0150606","2825136","3537502"}

    Returns: 148

  53. {"7649767","3568447","9320014","5770586","0353083","9944654","6632388"}

    Returns: 143

  54. {"7328844","9089802","3702075","8442011","8639605","1014915","6300867"}

    Returns: 142

  55. {"3646821","1131841","2528692","4408897","5213056","3911329","4090973"}

    Returns: 137

  56. {"0803351","7537624","8510564","2670434","4802589","6380604","6549540"}

    Returns: 131

  57. {"4129219","8944414","4601043","9475870","9949326","1231951","2394992"}

    Returns: 144

  58. {"2845240","1021314","8289904","5993531","9339479","5548693","6691099"}

    Returns: 155

  59. {"5587919","7818044","6964050","1383067","3249952","4111316","6883772"}

    Returns: 144

  60. {"4262397","6453081","6818607","8321562","7694945","6770012","3537451"}

    Returns: 128

  61. {"5699609","7801869","4360070","6421765","2073344","6091816","0072509"}

    Returns: 142

  62. {"1205731","7913680","9848019","5737434","0717667","2854843","2404115"}

    Returns: 138

  63. {"2779956","7493537","5593567","8963751","8031759","7352958","9036422"}

    Returns: 147

  64. {"8466483","8599020","1735732","9534703","2698519","6405706","6363253"}

    Returns: 146

  65. {"8845131","5242270","2398697","3945747","2262017","1171740","8591523"}

    Returns: 133

  66. {"1961145","5053502","0359421","5390225","8369727","1861735","5045022"}

    Returns: 121

  67. {"4904937","1679412","7060001","7332685","6843800","9221900","1694181"}

    Returns: 123

  68. {"9663530","3631867","0908340","9618575","4692368","7977876","8719900"}

    Returns: 145

  69. {"8114541","6425688","1233247","6540282","9487819","3532647","3401382"}

    Returns: 136

  70. {"0909355","4463494","6616430","0782571","8593850","1531824","5902715"}

    Returns: 128

  71. {"3426967","3986014","5381713","0386719","9699606","3197635","9908849"}

    Returns: 154


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: