Page 17 of 17

Re: 195 - Anagram

Posted: Fri Feb 05, 2016 10:33 pm
by alekscooper
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 )

Re: 195 - Anagram

Posted: Tue Apr 05, 2016 3:36 pm
by 4rchitect
Is there a way to use std function lexicographical_compare and sort to sort the way the problem wants?

Re: 195 - Anagram

Posted: Sat Apr 16, 2016 4:24 pm
by metaphysis
I think the answer is negative. You should code a custom compare function as parameter for sort.