Title: Two Sum in Python - Runnable Code Snippet
Open Graph Title: Two Sum in Python - Runnable Code Snippet
X Title: Two Sum in Python - Runnable Code Snippet
Description: Find indices of two numbers in an array that add up to a target value using a hash map for O(n) time complexity. Runnable Python snippet with live execution.
Open Graph Description: Find indices of two numbers in an array that add up to a target value using a hash map for O(n) time complexity. Runnable Python snippet with live execution.
X Description: Find indices of two numbers in an array that add up to a target value using a hash map for O(n) time complexity. Runnable Python snippet with live execution.
Keywords:
Opengraph URL: https://tempercode.dev/snippets/two-sum-python
Domain: tempercode.dev
{"@context":"https://schema.org","@type":"SoftwareSourceCode","name":"Two Sum","description":"Find indices of two numbers in an array that add up to a target value using a hash map for O(n) time complexity.","programmingLanguage":"Python","text":"seen = {}\nresult = None\nfor i, num in enumerate(arr):\n complement = target - num\n if complement in seen:\n result = [seen[complement], i]\n break\n seen[num] = i\nresult"}
| theme-color | #0c0d12 |
| color-scheme | dark |
| author | Temper |
| creator | Temper |
| publisher | Temper |
| og:image | https://tempercode.dev/og-image.png |
| og:type | article |
| twitter:card | summary_large_image |
| twitter:image | https://tempercode.dev/og-image.png |
Links:
Viewport: width=device-width, initial-scale=1