Programming

  • Published on
    The Two Sum problem involves finding indices of two numbers in an array that add up to a target. The brute force method is inefficient (O(n²)), while the hash map approach is faster (O(n)), highlighting the importance of efficient problem-solving techniques.
  • Published on
    Starting my Leetcode journey, I tackled the Contains Duplicate problem. The brute force solution has O(n²) complexity, while using a set improves efficiency to O(n). This highlights the value of sets for quick existence checks in programming challenges.
  • Published on
    The Valid Anagram problem checks if two strings are anagrams. The brute force method is inefficient (O(mn)), while sorting improves it to O(m log(m) + n log(n)). Using a hash map offers the best efficiency at O(m+n), balancing speed and memory.