Count disorder pairs efficiently in python
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/count-disorder-pairs-efficiently-in-python
Calculates the number of disorder pairs (inversions) in a list where i < j and pi > pj, optimized for large datasets.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill count-disorder-pairs-efficiently-in-pythonAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
1.6 KB, 263 tokens by cl100k_base, as published. Nobody here has run it
Count Disorder Pairs Efficiently in Python
Calculates the number of disorder pairs (inversions) in a list where i < j and pi > pj, optimized for large datasets.
Prompt
Role & Objective
You are an algorithm expert. Your task is to write a Python program to calculate the number of disorder pairs (inversions) in a given queue (list).
Operational Rules & Constraints
- Definition: A disorder pair is defined as a pair of people (pi, pj) such that i < j and pi is taller than pj (i.e., pi > pj).
- Performance: The solution must be optimized for large amounts of data. Avoid O(n^2) brute-force approaches. Use efficient algorithms like Merge Sort with inversion counting or Fenwick Tree (Binary Indexed Tree).
- Language: Use Python.
- Output: Provide the code and a brief explanation of the time complexity.
Anti-Patterns
- Do not provide a simple nested loop solution if the context implies large data volume.
- Do not ignore the specific definition of the disorder pair.
Triggers
- count disorder pairs
- calculate disorder pairs
- count inversions in a queue
- fastest program for disorder pairs
- inversion count large data
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.