
Leetcode problems 1-100
附近得人
东北大学学生
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Leetcode 34. Find First and Last Position of Element in Sorted Array
Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the t...原创 2019-06-12 21:06:45 · 138 阅读 · 0 评论 -
Leetcode 41. First Missing Positive
Leetcode 41. First Missing PositivePython 解题思路class Solution: def firstMissingPositive(self, nums): nums.sort() res = 1 for num in nums: if num == res: ...原创 2019-06-29 19:24:32 · 141 阅读 · 0 评论 -
Leetcode 40. Combination Sum II
Leetcode 40. Combination Sum IIPython 解题思路class Solution: def __init__(self): self.res = [] self.path = [] self.candidates = [] def dfs(self, target, ind): i...原创 2019-06-29 17:11:11 · 146 阅读 · 0 评论 -
Leetcode 43. Multiply Strings
Leetcode 43. Multiply StringsPython 解题思路class Solution: def multiply(self, num1, num2): num1, num2 = int(num1), int(num2) ret = return str(num1 * num2)solu = Solution()...原创 2019-06-29 17:07:19 · 153 阅读 · 0 评论 -
Leetcode 31. Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible or...原创 2019-06-04 20:31:39 · 109 阅读 · 0 评论 -
Leetcode 30. Substring with Concatenation of All Words
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and wi...原创 2019-06-04 19:43:00 · 143 阅读 · 0 评论 -
Leetcode 24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.You may not modify the values in the list’s nodes, only nodes itself may be changed.Example:Given 1->2->3->4, you sho...原创 2019-06-03 18:32:20 · 129 阅读 · 0 评论 -
Leetcode 25.Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If the number of n...原创 2019-06-03 19:29:33 · 143 阅读 · 0 评论 -
Leetcode 26. Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyin...原创 2019-06-03 19:47:28 · 119 阅读 · 0 评论 -
Leetcode 27. Remove Element
Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array...原创 2019-06-03 20:32:15 · 121 阅读 · 0 评论 -
Leetcode 28. Implement strStr()
Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = “hello”, needle = “ll”Output: 2Example 2:Input: haystack = “aaa...原创 2019-06-03 20:40:17 · 106 阅读 · 0 评论 -
Leetcode 29. Divide Two Integers
Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.Return the quotient after dividing dividend by divisor.The integer division shoul...原创 2019-06-03 20:59:29 · 223 阅读 · 0 评论 -
Leetcode 39. Combination Sum
iven a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.The same repeated...原创 2019-06-14 15:46:25 · 167 阅读 · 0 评论 -
Leetcode 37. Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules:Each of the digits 1-9 must occur exactly once in each row.Each of the ...原创 2019-06-14 14:08:03 · 165 阅读 · 0 评论 -
Leetcode 36. Valid Sudoku
Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 without repetition.Each column must contain...原创 2019-06-14 13:21:37 · 153 阅读 · 0 评论 -
Leetcode 35. Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Ex...原创 2019-06-12 21:14:40 · 116 阅读 · 0 评论 -
Leetcode 42. Trapping Rain Water
Leetcode 42. Trapping Rain WaterPython 解题思路class Solution(object): def trap(self, height): res = 0 mx = 0 n = len(height) dp = [] for i in range(n): ...原创 2019-06-29 19:25:38 · 158 阅读 · 0 评论