aspose file tools
The moose likes Beginning Java and the fly likes Duplicate array element ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Duplicate array element ?" Watch "Duplicate array element ?" New topic
Author

Duplicate array element ?

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1300
My array has ccdddeeeettttauu. I want to find which letter position is not in order, in this case letter 'a' and which letter is duplicate(more than one time).
Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

hello,
you must try and think about the ways that will help you to solve this problem , we are here to help you not to provide solution.


I Hear I Forget, I See I Remember, I Do I Understand.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

When is a character out of order? If it comes alphabetically before the previous character, right? So compare each character (except the first) to the previous character, and if it's smaller it's out of order.

When is a character a duplicate? If it already was encountered in the String, right? Now, you can't simply compare a character to its previous character to see if it matches, because a String of "tat" still has duplicates. So you need to a) compare each character with all characters before or after it (both is not necessary), or b) keep track of which characters you already encountered and see if the current character is one of those.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Duplicate array element ?
 
Similar Threads
Dan's Collection: Duplicate elements must not replace old elements
java error
Dan's questions
Java array and String problem
import static question