# Overthinking Leetcode's Two Sum with SIMD

DevFeed: [Overthinking Leetcode's Two Sum with SIMD](<https://devfeed.tech/articles/overthinking-leetcode-s-two-sum-with-simd-35478.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/two-sum/>)

Author: Graham King

Published: 2022-10-09T07:00:00Z

Content type: tutorial

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Algorithms](<https://devfeed.tech/topics/algorithms.md>), [Code](<https://devfeed.tech/topics/code.md>), [Rust](<https://devfeed.tech/topics/rust.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [array](<https://devfeed.tech/tags/array.md>), [avx](<https://devfeed.tech/tags/avx.md>), [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [code](<https://devfeed.tech/tags/code.md>), [complexity](<https://devfeed.tech/tags/complexity.md>), [interview](<https://devfeed.tech/tags/interview.md>), [performance](<https://devfeed.tech/tags/performance.md>), [rust](<https://devfeed.tech/tags/rust.md>), [simd](<https://devfeed.tech/tags/simd.md>), [software](<https://devfeed.tech/tags/software.md>)

## AI overview

This article examines the Two Sum problem by comparing a brute-force linear scan with a map-based solution. It discusses their complexity, implementation costs, and when the linear approach may be faster, including the possibility of using AVX-512 instructions.

## Source excerpt

When is the linear scan Two Sum solution faster than a map? What if we use AVX-512 instructions?