Solution to LeetCode Problem Set

Here is my collection of solutions to leetcode problems.

LeetCode - Course Schedule

LeetCode - Reverse Linked List

LeetCode - Isomorphic Strings

LeetCode - Count Primes

LeetCode - Remove Linked List Elements

LeetCode - Happy Number

LeetCode - Bitwise AND of Numbers Range

LeetCode - Number of Islands

LeetCode - Binary Tree Right Side View

LeetCode - House Robber

LeetCode - Number of 1 Bits

LeetCode - Reverse Bits

LeetCode - Rotate Array

LeetCode - Best Time to Buy and Sell Stock IV

LeetCode - Repeated DNA Sequences

LeetCode - Largest Number

LeetCode - Dungeon Game

LeetCode - Binary Search Tree Iterator

LeetCode - Factorial Trailing Zeroes

LeetCode - Excel Sheet Column Number

LeetCode - Majority Element

LeetCode - Excel Sheet Column Title

LeetCode - Fraction to Recurring Decimal

LeetCode - Compare Version Numbers

LeetCode - Maximum Gap

LeetCode - Find Peak Element

LeetCode - Intersection of Two Linked Lists

LeetCode - Min Stack

LeetCode - Find Minimum in Rotated Sorted Array II

LeetCode - Find Minimum in Rotated Sorted Array

LeetCode - Reverse Words in a String

LeetCode - Regular Expression Matching

LeetCode - Sudoku Solver

LeetCode - Implement strStr()

LeetCode - Wildcard Matching

LeetCode - Word Ladder II

LeetCode - Word Ladder

LeetCode - Word Break II

LeetCode - Word Break

LeetCode - Valid Number

LeetCode - Surrounded Regions

LeetCode - Substring with Concatenation of All Words

LeetCode - Scramble String

LeetCode - Word Search

LeetCode - Reverse Nodes in k-Group

LeetCode - Palindrome Partitioning II

LeetCode - Palindrome Partitioning

LeetCode - Merge Interval

LeetCode - Minimum Window Substring

LeetCode - Maximal Rectangle

LeetCode - Max Points on a Line

LeetCode - Largest Rectangle in Histogram

LeetCode - Jump Game II

LeetCode - Jump Game

LeetCode - Interleaving String

LeetCode - Gas Station

LeetCode - Evaluate Reverse Polish Notation

LeetCode - Edit Distance

LeetCode - Clone Graph

LeetCode - Candy

LeetCode - 3Sum Closest

LeetCode - Set Matrix Zeroes

LeetCode - Search for a Range

LeetCode - N-Queens II

LeetCode - N-Queens

LeetCode - LRU Cache

LeetCode - Longest Valid Parentheses

LeetCode - Insert Interval

LeetCode - Flatten Binary Tree to Linked List

LeetCode - Convert Sorted List to Binary Search Tree

LeetCode - Binary Tree Maximum Path Sum

LeetCode - Trapping Rain Water

LeetCode - Unique Binary Search Trees II

LeetCode - Text Justification

LeetCode - String to Integer (atoi)

LeetCode - Longest Palindromic Substring

LeetCode - Permutation Sequence

LeetCode - First Missing Positive

LeetCode - Distinct Subsequences

LeetCode - Container With Most Water

LeetCode - 4Sum

LeetCode - Sort List

LeetCode - Insertion Sort List

LeetCode - Binary Tree Postorder Traversal

LeetCode - Binary Tree Preorder Traversal

LeetCode - Reorder List

LeetCode - Linked List Cycle II

LeetCode - Linked List Cycle

LeetCode - Copy List with Random Pointer

LeetCode - Single Number II

LeetCode - Single Number

LeetCode - Sum Root to Leaf Numbers

LeetCode - Longest Consecutive Sequence

LeetCode - Valid Palindrome

LeetCode - Best Time to Buy and Sell Stock III

LeetCode - Best Time to Buy and Sell Stock II

LeetCode - Best Time to Buy and Sell Stock

LeetCode - Triangle

LeetCode - Pascal‘s Triangle II

LeetCode - Pascal‘s Triangle

LeetCode - Populating Next Right Pointers in Each Node II

LeetCode - Populating Next Right Pointers in Each Node

LeetCode - Path Sum II

LeetCode - Path Sum

LeetCode - Minimum Depth of Binary Tree

LeetCode - Balanced Binary Tree

LeetCode - Convert Sorted Array to Binary Search Tree

LeetCode - Binary Tree Level Order Traversal II

LeetCode - Construct Binary Tree from Inorder and Postorder Traversal

LeetCode - Construct Binary Tree from Preorder and Inorder Traversal

LeetCode - Maximum Depth of Binary Tree

LeetCode - Binary Tree Zigzag Level Order Traversal

LeetCode - Binary Tree Level Order Traversal

LeetCode - Symmetric Tree

LeetCode - Same Tree

LeetCode - Recover Binary Search Tree

LeetCode - Validate Binary Search Tree

LeetCode - Unique Binary Search Trees

LeetCode - Binary Tree Inorder Traversal

LeetCode - Restore IP Addresses

LeetCode - Reverse Linked List II

LeetCode - Subsets II

LeetCode - Decode Ways

LeetCode - Gray Code

LeetCode - Merge Sorted Array

LeetCode - Partition List

LeetCode - Remove Duplicates from Sorted List II

LeetCode - Remove Duplicates from Sorted List

LeetCode - Search in Rotated Sorted Array II

LeetCode - Remove Duplicates from Sorted Array II

LeetCode - Subsets

LeetCode - Combinations

LeetCode - Sort Colors

LeetCode - Search a 2D Matrix

LeetCode - Simplify Path

LeetCode - Climbing Stairs

LeetCode - Sqrt(x)

LeetCode - Plus One

LeetCode - Add Binary

LeetCode - Merge Two Sorted Lists

LeetCode - Minimum Path Sum

LeetCode - Unique Paths II

LeetCode - Unique Paths

LeetCode - Rotate List

LeetCode - Spiral Matrix II

LeetCode - Length of Last Word

LeetCode - Spiral Matrix

LeetCode - Maximum Subarray

LeetCode - Pow(x, n)

LeetCode - Anagrams

LeetCode - Rotate Image

LeetCode - Permutations II

LeetCode - Permutations

LeetCode - Multiply Strings

LeetCode - Combination Sum II

LeetCode - Combination Sum

LeetCode - Count and Say

LeetCode - Valid Sudoku

LeetCode - Search Insert Position

LeetCode - Search in Rotated Sorted Array

LeetCode - Next Permutation

LeetCode - Divide Two Integers

LeetCode - Remove Element

LeetCode - Remove Duplicates from Sorted Array

LeetCode - Swap Nodes in Pairs

LeetCode - Merge k Sorted Lists

LeetCode - Generate Parentheses

LeetCode - Valid Parentheses

LeetCode - Remove Nth Node From End of List

LeetCode - Letter Combinations of a Phone Number

LeetCode - 3Sum

LeetCode - Longest Common Prefix

LeetCode - Roman to Integer

LeetCode - Integer to Roman

LeetCode - Palindrome Number

LeetCode - Reverse Integer

LeetCode - ZigZag Conversion

LeetCode - Add Two Numbers

LeetCode - Longest Substring Without Repeating Characters

LeetCode - Median of Two Sorted Arrays

LeetCode - Two Sum

时间: 2024-12-22 05:15:13

Solution to LeetCode Problem Set的相关文章

LeetCode Problem 90. Subsets II

python solution 123456789101112131415161718192021222324252627 class (object): def subsetsWithDup(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ """ 思路整理:DFS recursion 1)对nums进行排序以避免nums中重复元素

an optimal solution to the problem

http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/Greedy/greedyIntro.htm Greedy Introduction Greedy algorithms are simple and straightforward. They are shortsighted in their approach in the sense that they take decisions on the basis of

LeetCode Problem: Majority Element查找多数元素

描述:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always exist in the array. 思路1:Moore voting algorith

LeetCode Problem 2:Two Sum

描述: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note t

LeetCode Problem 9:Palindrome Number回文数

描述:Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string, note the restriction of using extra space. You could a

Edit Distance (or Levenshtein Distance) python solution for leetcode EPI 17.2

https://oj.leetcode.com/problems/edit-distance/ Edit Distance  Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted

leetcode problem (5)

最长回文子串: 1. 暴力搜索   时间复杂度O(n^3) 2. 动态规划 dp[i][j] 表示子串s[i…j]是否是回文 初始化:dp[i][i] = true (0 <= i <= n-1);  dp[i][i-1] = true (1 <= i <= n-1); 其余的初始化为false dp[i][j] = (s[i] == s[j] && dp[i+1][j-1] == true) 时间复杂度O(n^2),空间O(n^2) 3.  以某个元素为中心,分别

leetcode problem 42 -- Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. The above elevation map is represented by a

leetcode problem (2-4)

Problem 2 --- Add Two Numbers 简单的模拟题. Problem 3 --- Longest Substring Without Repeating Characters 题意: 给定一个字符串序列,找出最长无重复的子序列.如"abcabcbb"的最长不重复子序列为"abc" 思路: 首先分配一个hashTable[256],里面保存每个字符在当前字符序列中的位置,同时设置left变量表示当前无重复字符串的最左端位置.然后从头到尾扫面字符串