№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
Hi,
I am having a little difficulty in understanding how the values are inserted into the TreeMap in a sorted order. Take a look at this code in a class that implements comparable
public int compareTo(STR other)
{
if(this.val==other.val) return this.team.compareTo(other.team);
return this.val>other.val?-1:1;
}
I dont understand why -1 is returned when this.val>other.val (The problem requires that the objects be sorted in decreasing order of values). Also, what is returned by
return this.team.compareTo(other.team) /* team is a String data
Also, the method compareTo is not called anywhere. So,where do the above return statements go to ? Does this occur implicitly whenever values are inserted into the TreeMap? Thanks for the help.
Suppose you are given three strings of English letters X = x1x2…xm, Y = y1y2…ym, Z = z1z2…zm+n. The string Z is a shuffle of X and Y if and only if Z can be formed by interspersing the characters from X and Y in a way that preserves the left-to-right ordering of the characters from X and Y respectively. For example, cchocohilaptes is a shuffle of chocolate and chips, but chcccochilatspe is not.
Find a DP algorithm to determine whether Z is a shuffle of X and Y .
Hi,
Can someone tell me on what basis you decide that a naive solution will cause time exceeded error ? I have faced this problem quite a few times.
Название |
---|