forked from wisdompeak/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
806c27d
commit 9484224
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <ext/pb_ds/assoc_container.hpp> // Common file | ||
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update | ||
using namespace __gnu_pbds; | ||
|
||
typedef tree< | ||
int , | ||
null_type, | ||
less<int>, | ||
rb_tree_tag, | ||
tree_order_statistics_node_update> | ||
ordered_set; | ||
|
||
int main() { | ||
ordered_set Set; | ||
vector<int>nums({1,3,2,2,4,4,8,6,7,3}); | ||
for (int i=0; i<nums.size(); i++) | ||
{ | ||
Set.insert(nums[i]); | ||
cout<<nums[i]<<":"<<Set.order_of_key(nums[i])<<endl; | ||
} | ||
} | ||
// If you want to make it like a multiset, you may design the base type of the ordered_set as pair<int,int> |