Home › Prompts › DeepSeek › Design an algorithm with complexity analysis

Design an algorithm with complexity analysis

Design an algorithm for a problem, compare approaches and analyze time and memory.

DeepSeekCodingRuleStack original

Written for DeepSeek Chat (DeepThink reasoning mode) · Updated 2026-10-17

Note: Review and test before use. Provided as is, without warranty. See Terms.

Prompt

Download  
Problem: [problem statement with input size limits].
Give 2 approaches: a simple one and an efficient one. For each: idea, pseudocode, time and space complexity, and when it breaks. Then implement the efficient one in [language] with tests for edge cases.

Replace everything in [square brackets] with your own details.

Settings & parameters

Variations

Tips

More: all DeepSeek prompts · all coding prompts · prompt library

Related prompts

Refactor plan for messy code

Get a safe, step-by-step refactor plan for a piece of code, with tests to add first.

DeepSeekCoding

Debug with ranked hypotheses

Debug a problem by listing likely causes, quick tests for each, and the fix for the confirmed cause.

DeepSeekCoding

Debug an error with hypotheses

A debugging prompt that makes the model rank hypotheses and suggest the fastest checks instead of guessing a fix.

ChatGPTCoding

Build a small interactive tool as an artifact

Ask Claude to build a single-file interactive tool in an artifact, like a calculator or checklist, that you can use right away.

ClaudeCoding

Thorough pull request review

A structured code review focused on correctness, security and maintainability, with severity labels and concrete fixes.

ClaudeCoding

Generate meaningful unit tests

Tests that cover behavior, edge cases and failure modes for a function, in your framework's style.

ClaudeCoding

Get the best new AI prompts every week

One short email a week: the best new prompts and rules for ChatGPT, Claude, Gemini, Midjourney, Cursor and more, plus what changed in the tools. Free, unsubscribe anytime.

Finishes on our newsletter page at beehiiv (opens in a new tab). Or subscribe directly.