Ritesh Pareek wrote:
For the directories given by you ... according my algorithm it will be
c:\checko~1\foo
c:\checko~1\foo
No, This must be like
c:\checko~1\foo
c:\checko~2\foo
java.lang.String API having this solution. Algo should be look like this
loop1 while mainStr not null
resArr[count++] = mainStr.slice(indexof("\\"))
end Loop2
loop2 while resArr
1. you can use selection/binary sorting here
2. truncate tailing chars with ~1
3. do compare array element for 8 char similar string.
4. if similar truncate tailing chars with ~2,3,4... so on
David Newton wrote:Right, what I'm saying is that the two different directories would map to the same shortened string, which is a Bad Thing.
David Newton wrote:Seems like you have all the steps--what, specifically, are you having a problem with?
Be careful with this algorithm, though--what would happen if you had these two directories?
c:\check out\foo
c:\check out this\foo