Sales AgentsADVANCEDGPT-3.54.9
Optimize a Python Function for Speed
Improve the performance of a given Python code snippet
The Prompt
Write a Python function that takes a large array of integers as input. This function should iterate over the array, find pairs of numbers that add up to a target value, and store them in a dictionary where the keys are the pairs and the values are their frequencies. The target value is the sum of all the elements in the array divided by 2. The function should return the dictionary. Use a single loop to iterate over the array, and employ techniques such as memoization or caching to improve performance. The input array will contain at least 100,000 elements and will be randomly generated.
Example Output
[{'(1, 100001)': 1, '(2, 100002)': 1, ...}]
Best Use Cases
Software Development & Coding
Frequently Asked Questions
What is the "Optimize a Python Function for Speed" prompt used for?
Improve the performance of a given Python code snippet
Which AI model works best with this prompt?
This prompt is optimized for GPT-3.5 but also works with Claude 3, Gemini Pro, and other LLMs.
Is this prompt free to use?
Yes — all PromptForgeHub prompts are free to copy and use. Click the copy button and paste into your AI tool.
How difficult is this prompt?
Difficulty: ADVANCED. Best suited for advanced prompt engineers.
More Sales Agents Prompts
AI Sales Objection Handling Script Generator
Generates scripts to handle common sales objections.
#sales#objection#closing
View Prompt
AI High Ticket Sales Call Script
Creates structured high-ticket closing scripts.
#sales#closing#high-ticket
View Prompt
Cold Email High-Converting Sales Script
Generates personalized cold email scripts.
#sales#cold-email#conversion
View Prompt
AI B2B LinkedIn Outreach Message Builder
Creates personalized LinkedIn sales messages.
#linkedin#b2b#sales
View Prompt
Details
Need Custom Prompts?
Our team of prompt engineers can build custom AI workflows for your business needs.
Contact SalesExplore 1,000+ more AI prompts for business, marketing, eCommerce & more.
Browse All Prompts