Conversation
| @@ -48,6 +48,8 @@ public void testRemoveDuplicatesExactly2() { | |||
|
|
|||
| @Test | |||
| public void testRemoveDuplicatesExactly3() { | |||
There was a problem hiding this comment.
If I recall correctly this test was broken before. In this case its fine that you edited the test, but in the future it would be preferred if you just took the changes from our the zipcoder github by fetching/pulling instead of just copy/pasting.
| count = 0; | ||
| } | ||
| if (nonDups == "") { | ||
| String[] emptyArray = new String[0]; |
There was a problem hiding this comment.
I don't understand what this is here for? If every item is a dupe, shouldn't you just return an empty array?
| if (nonDups == "") { | ||
| String[] emptyArray = new String[0]; | ||
| Integer[] emptyfinalIntArr = new Integer[emptyArray.length]; | ||
| for (int m = 0; m < emptyfinalIntArr.length; m++) { |
There was a problem hiding this comment.
emptyfinalIntArr is going to be 0 so this code is never going to run
| finalIntArr[m] = Integer.parseInt(finalStringArr[m]); | ||
| } | ||
| return finalIntArr; | ||
| } |
There was a problem hiding this comment.
while this code technically works, converting from string to integer is a dangerous parse and should be avoided if possible.
| finalIntArr[m] = Integer.parseInt(finalStringArr[m]); | ||
| } | ||
| return finalIntArr; | ||
|
|
There was a problem hiding this comment.
again, while this technically works, parsing from string to integer is a dangerous operation and should be avoided if possible.
| } | ||
| if (nonDups == ""){ | ||
| String [] emptyArray = new String[0]; | ||
| return emptyArray; |
There was a problem hiding this comment.
just return new String[0] for the same result. This is wasted code.
| } | ||
| else { | ||
| String [] finalString = nonDups.split(" ") ; | ||
| return finalString; |
There was a problem hiding this comment.
just return nonDups.split(" ")
| count = 0; | ||
| } | ||
|
|
||
| String[] finalString = nonDups.split(" "); |
There was a problem hiding this comment.
Honestly not sure how this is getting the right answer. If you add a space after every single nonDup, (e.g. underscores for spaces a_b_c_ then your split array should be ["a", "b", "c", ""]. Make sure you trim the excess space before splitting by space.
No description provided.