Skip to content
hakk
  • Home
  • Blog
  • Docs
  • DSA
  • Snippets

Sorting

  • Two Sum 2022-06-19

    Given an array of unsorted numbers nums and an integer target, find two integers in the array that sum to the target and return their indices.

    There are three ways that I know of to solve this problem. Below you’ll find a description of each with some brief code examples. I would like to encourage you to try to implement your own solution first before scrolling down.

    Solution 1: Brute Force

    The first way, which is the brute force method, is to use nested loops. It tries every possible combination by looping over and take exponential time.

Recent posts
  • How to Update a File's Creation Time in PowerShell
  • How to Run PowerShell Code Only During Certain Times
  • PeopleSoft App Server Freeze Troubleshooting Checklist
  • Build Vim With Python3 Support
  • Understanding the ss Command: A Modern Alternative to netstat
© 2026 hakk
  • Home
  • Blog
  • Docs
  • DSA
  • Snippets