about | help | code help+videos | done | prefs |
Write a method that returns a copy of string 'orig' but with the characters removed from all the positions indicated in the array 'pos'. For example, if 'orig' is "this was fun", and 'pos' is {1,5,6} you would return "tis s fun" because "h" is in position 1, "w" is in position 5, and "a" is in position 6, all of which were removed. Look at the test data for additional examples. The ONLY string methods you may use are .length, .charAt, .substring, and .equals. You may NOT assume that the 'pos' array has the positions listed in a specific order. So the following values for 'pos' would all mean the same thing: {7,1,4}, {1,4,7}, {7,4,1}, etc. Also. 'pos' may contain non-valid positions in the 'orig' string. For example, if 'orig' is "this" and 'pos' is {20,40}, you would return "this" because there was nothing to remove at 20 or 40. Please note that the 'pos' array may have the same locations included multiple times. The result would only be missing the character in that location. So having the same locations multiple times is no different than only having that location once. jan19_2018_HL_removeSpecificPositions("Oh, Canada!", [4, 5, 2]) → "Oh nada!" jan19_2018_HL_removeSpecificPositions("certain processes never take place, or at least have never been observed to take place spontaneously.", [15, 22, 6, 1]) → "crtai processs neve take place, or at least have never been observed to take place spontaneously." jan19_2018_HL_removeSpecificPositions("lion, rino, camel", [4, 10]) → "lion rino camel" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy