Skill · Code & Agents
Algorithm Designer
Turns a problem and its limits into an algorithm that provably fits them, with an invariant, a hand trace and a brute-force comparison test.
When to use
- A problem has no obvious library call and needs an efficient approach.
- Code is correct but too slow on real input sizes, and the fix is a better algorithm rather than micro-optimisation.
- Interview or contest practice where the reasoning matters as much as the answer.
When not to use
- The slow part is I/O, database queries or network calls. Profile first; a better algorithm will not help.
- The problem is a textbook one with a library implementation. The skill will name it and stop, so you can skip straight to the library.
Example
User: An array of up to 10^5 integers and a target k. Count pairs i < j with a[i] + a[j] = k. Python.
Result (excerpt):
Problem: count index pairs summing to k · Limits: n ≤ 10^5, values fit in 32 bits · Budget: O(n log n)
Standard problem? Close to two-sum, but counting all pairs; adapting it.
Brute force: check every pair · O(n^2) ≈ 5·10^9 steps: too slow
Candidates:
| sort + two pointers | O(n log n) | fits; runs of duplicates need care |
| counts of values seen so far | O(n) | fits; simplest |
Chosen: running counts
count = 0; seen = empty map
for x in a: count += seen[k - x] (0 if absent); seen[x] += 1
Why it is correct: before index j is processed, seen holds a[0..j-1], so each pair is counted once, at its larger index.
Trace: a = [1, 3, 2, 2], k = 4 → 0, 1, 1, 2 → 2, matches brute force
Edge cases: n < 2 → 0 · all values equal to k/2 → n(n−1)/2
Verification: 300 random arrays, n ≤ 8, values 0..5 · not run here: python test_pairs.py
Pitfalls (Python): read input with sys.stdin; the count can reach about 5·10^9, so use 64-bit integers if you port it to Java or C++.
Illustrative example written by Meevra; your model's wording will differ.
What is inside
The full skill has these sections. The ones marked “in the pack” come with the download.
- When to use on this page
- When not to use on this page
- Inputs to ask for in the pack
- Workflow in the pack
- Output format in the pack
- Example on this page
- Model notes (Oct 2026) in the pack
- Troubleshooting in the pack
Get Algorithm Designer
The full skill is a SKILL.md folder you install once and reuse: the workflow, the checklist and the answer format written out, with notes for each model. It comes in the Code & Agents pack (5 prompts · 15 skills · 1 free), with a QUICKSTART, setup notes in every item and 12 months of updates.
All-Access 39 € vs 7 packs × 12 € = 84 € · less than buying 4 or more packs one by one
Stuck? Email support@meevra.com — we'll help you set it up.