Is there any way to find index of an element in a treeset in java?
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Is there any way to find index of an element in a treeset in java?
Name |
---|
Auto comment: topic has been updated by ninjamayank (previous revision, new revision, compare).
why not? iterate over all elements, maintain a counter. when you meet your desired element you return the value of the counter. The time complexity is linear in size of the treeset. but I'm guessing this is not what you're looking for.
Everything is possible — Barrack Schwarzenegger, 2025.
Thanks for the reply but I needed a way to do it in logn time
Sighs. You can't
Just use C.
Marinush
with Treeset, there isn't besides doing linear, however you could implement our own binary tree and use binary search to localize the element. Another option would be use FendWick Tree
Thank you for the advice
Refer to this
Thank you very much. It really helped.
What problem caused you to need such a data structure though, I'm curious?
https://codeforces.me/contest/1679/problem/C