Algorithm and Data Structure Selection Review
Replace slow structures with suitable ones.
The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.
Review code for slow algorithm or data structure choices. Language: [LANGUAGE]. Code to review: [PASTE_CODE]. Typical and maximum input sizes: [INPUT_SIZES]. Performance requirement: [REQUIREMENT]. Return the review as BEFORE and AFTER pairs for every issue. For each issue: BEFORE: the quoted code, its time and memory complexity in big-O terms, and a one-sentence explanation of why it is slow at my input sizes (do the arithmetic: for example, 100,000 items with a nested loop means about 10 billion comparisons). AFTER: the replacement code, its new complexity, and what data structure changed (list to set or dictionary, repeated sorting to a heap, string concatenation to a builder, repeated lookups to a precomputed index). RISK: what behavior could change (ordering, duplicates, memory use), and the test that proves equal results. Rank the issues by expected gain at my input sizes, and clearly mark those that are not worth changing at my scale. Provide a small benchmark script I can run to compare. Do not optimize code that is not on a hot path, and say how to find the hot path with a profiler first.
Fill in before use
Optional: type your details and the prompt above updates. Nothing is saved or sent.
Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.