Skip to content

OmPreetham/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode

A collection of my solutions to LeetCode problems, written for learning, practice, and fun.
Each solution is written with readability and efficiency in mind.


Structure

Each file is named after the problem title or number, e.g. 0001-two-sum.js.


Topics

  • Arrays & Strings
  • Hash Maps
  • Two Pointers
  • Sliding Window
  • Recursion & Backtracking
  • Trees & Graphs
  • Dynamic Programming
  • Greedy Algorithms

Example

// 1. Two Sum
var twoSum = function(nums, target) {
    const map = new Map();
    for (let i = 0; i < nums.length; i++) {
        const diff = target - nums[i];
        if (map.has(diff)) {
            return [map.get(diff), i];
        }
        map.set(nums[i], i);
    }
};