joseavr / leetcode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LeetCode Practice Repository

Welcome to my LeetCode practice repository! Here you'll find solutions to various problems from LeetCode, categorized by topic. This repository is meant to serve as a resource for practicing coding skills, particularly in areas such as arrays, graphs, and more.

Table of Contents

Arrays

Arrays are one of the fundamental data structures in computer science. They consist of a collection of elements, each identified by at least one array index or key.

  1. Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

  2. Maximum Subarray - Find the contiguous subarray within an array (containing at least one number) which has the largest sum.

Strings

Strings are a sequence of characters, either as a literal constant or as some kind of variable. They are one of the most commonly used data types in programming.

  1. Reverse String - Write a function that reverses a string. The input string is given as an array of characters s.

  2. Valid Palindrome - Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.

Linked Lists

Linked lists are linear data structures where each element is a separate object, called a node, comprising a data and a reference or pointer to the next node in the sequence.

  1. Merge Two Sorted Lists - Merge two sorted linked lists and return it as a new sorted list.

  2. Linked List Cycle - Given a linked list, determine if it has a cycle in it.

Trees

Trees are hierarchical data structures consisting of nodes connected by edges. Each node has a value and a list of references to other nodes.

  1. Binary Tree Inorder Traversal - Given the root of a binary tree, return the inorder traversal of its nodes' values.

  2. Maximum Depth of Binary Tree - Given a binary tree, find its maximum depth.

Graphs

Graphs are a set of vertices (nodes) connected by edges. They are used to model pairwise relationships between objects.

  1. Number of Islands - Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.

  2. Course Schedule - There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai.

Dynamic Programming

Dynamic programming is a method for solving complex problems by breaking them down into simpler subproblems. It's particularly useful for optimization problems.

  1. Climbing Stairs - You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

  2. Maximum Subarray - Find the contiguous subarray within an array (containing at least one number) which has the largest sum.

Other Topics

This section includes problems that don't fit neatly into the previous categories but are still important for coding interviews and competitive programming.

  1. LRU Cache - Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.

  2. Median of Two Sorted Arrays - Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

Feel free to explore the solutions and contribute your own! Happy coding!


This template provides a structured overview of common LeetCode topics and links to solutions within the repository. You can further customize it based on your specific needs and preferences.

About


Languages

Language:TypeScript 97.0%Language:JavaScript 3.0%