Question: Write a method which takes in a string and returns true if the string contains any letters twice. For example if passed Apple it would
Write a method which takes in a string and returns true if the string contains any letters twice. For example if passed "Apple" it would return true because 'P' is in there twice. Likewise if passed 'sausage' it would return true because 'S' is in there twice. If passed "final" it would return false. Suggestions: Convert the string to an array of characters, sort it then look for adjacent letters that are the same. For Java sorting an array: import.Java.util.Arrays; int[]myArray=new int[] {3,1,2}; Arrays.sort(myArray);
Step by Step Solution
3.42 Rating (155 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
