Hi everyone,
I wrote my solution in Java and here's what I did:
1) I worked with StringBuilders. I know that might be not the best option, but I'm a self-taught non-competitive guy who just learns how to code using UVa Judge.
2) The first thing I do is I sort my input string converted to StringBuilder. However, there's an implementation trick which I will talk about in 3)
3) The trick of this program is comparison, since "aaAabBbzZz" should be sorted into '"AaaaBbbZzz". To achieve that I wrote my own function to compare two chars which I call 'less' (following the name given by R. Sedgewick).
4) After that I just implemented the Narayana algorithm, which also uses my less(...) function.
My Java solution is 0.139.
If anyone needs the code, please write at akuptsov.hseATgmail.com
Sorry, I don't have a git yet, I'm a noob and perhaps I don't have super-cool code to brag about, haha )
195 - Anagram
Moderator: Board moderators
Re: 195 - Anagram
Is there a way to use std function lexicographical_compare and sort to sort the way the problem wants?
-
- Experienced poster
- Posts: 139
- Joined: Wed May 18, 2011 3:04 pm
Re: 195 - Anagram
I think the answer is negative. You should code a custom compare function as parameter for sort.
metaphysis: http://uhunt.onlinejudge.org/id/95895
My solutions for UVa problems: https://github.com/metaphysis/Code.
My solutions for UVa problems: https://github.com/metaphysis/Code.