随笔分类 -  LeetCode

上一页 1 2 3 下一页

[LeetCode] Weekly Challenge Perform String Shifts
摘要:You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [direction, amount]: direction can be 0 (for left 阅读全文

posted @ 2020-04-14 23:40 codingEskimo 阅读(203) 评论(0) 推荐(0)

[LeetCode] 525. Contiguous Array
摘要:Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: Example 2: Note: The length of the giv 阅读全文

posted @ 2020-04-14 09:30 codingEskimo 阅读(194) 评论(4) 推荐(0)

[LeetCode] 1046. Last Stone Weight
摘要:We have a collection of stones, each stone has a positive integer weight. Each turn, we choose the two heaviest stones and smash them together. Suppos 阅读全文

posted @ 2020-04-13 05:14 codingEskimo 阅读(165) 评论(0) 推荐(0)

[LeetCode] 543. Diameter of Binary Tree
摘要:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe 阅读全文

posted @ 2020-04-12 10:56 codingEskimo 阅读(113) 评论(0) 推荐(0)

[LeetCode] 155. Min Stack
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) Push element x onto stack. pop() Removes the 阅读全文

posted @ 2020-04-11 01:53 codingEskimo 阅读(105) 评论(0) 推荐(0)

[LeetCode] 844. Backspace String Compare
摘要:Given two strings S and T, return if they are equal when both are typed into empty text editors. means a backspace character. Example 1: Example 2: Ex 阅读全文

posted @ 2020-04-10 05:19 codingEskimo 阅读(131) 评论(0) 推荐(0)

[LeetCode] 876. Middle of the Linked List
摘要:Given a non empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middl 阅读全文

posted @ 2020-04-08 22:08 codingEskimo 阅读(102) 评论(0) 推荐(0)

[LeetCode] Weekly Challenge Counting Element
摘要:Given an integer array arr, count element x such that x + 1 is also in arr. If there're duplicates in arr, count them seperately. Example 1: Example 2 阅读全文

posted @ 2020-04-07 23:08 codingEskimo 阅读(197) 评论(0) 推荐(0)

[LeetCode] 49. Group Anagrams
摘要:Given an array of strings, group anagrams together. Example: Note: All inputs will be in lowercase. The order of your output does not matter. 这道题就是用每个 阅读全文

posted @ 2020-04-07 08:29 codingEskimo 阅读(124) 评论(0) 推荐(0)

[LeetCode] 121. Best Time to Buy And Sell Stock
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文

posted @ 2020-04-07 07:50 codingEskimo 阅读(114) 评论(0) 推荐(0)

[LeetCode] 283. Move Zeros
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non zero elements. Example: Input: 阅读全文

posted @ 2020-04-06 10:47 codingEskimo 阅读(105) 评论(0) 推荐(0)

[LeetCode] 53. Maximum SubArray
摘要:Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Inpu 阅读全文

posted @ 2020-04-06 10:22 codingEskimo 阅读(117) 评论(0) 推荐(0)

[LeetCode] 202. Happy Number
摘要:Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive intege 阅读全文

posted @ 2020-04-06 06:42 codingEskimo 阅读(146) 评论(0) 推荐(0)

[LeetCode] LeetCode Summary 汇总
摘要:从今天开始努力刷题,用这个帖子来记录刷题的进度。也方便自己的寻找。 题号 题目 复习 1 Two Sum Y 2 Add Two Numbers Y 3 Longest Substring Without Repeating Characters Y 4 Median of Two Sorted A 阅读全文

posted @ 2020-04-06 05:42 codingEskimo 阅读(244) 评论(0) 推荐(0)

[Leetcode] 136. Single Number
摘要:Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runti 阅读全文

posted @ 2020-04-06 05:35 codingEskimo 阅读(114) 评论(0) 推荐(0)

[LeetCode] 83. Remove Duplicates from Sorted List
摘要:这道题虽然简单,但是需要注意的点还是比较多,首先是如果一直有重复的duplicate,要把所有的都去掉,所以inner loop是while而不是if,其次是每一层loop结束的条件,要搞清楚是head,还是head.next是不是None。 最后学习一下在python中如何建立一个class并且写 阅读全文

posted @ 2020-01-26 02:47 codingEskimo 阅读(87) 评论(0) 推荐(0)

[LeetCode] 118.Pascal's Triangle
摘要:很简单的杨辉三角问题,时间复杂度是O(N), 空间复杂度是O(1) class Solution: def generate(self, numRows: int) -> List[List[int]]: if numRows == 0: return [] result = [[1]] for r 阅读全文

posted @ 2020-01-21 03:09 codingEskimo 阅读(99) 评论(0) 推荐(0)

[LeetCode] 67. Add Binary
摘要:这道题其实和其他类似问题很相似,就是要处理carry的问题。时间复杂度是O(N),空间复杂度是O(1) class Solution: def addBinary(self, a: str, b: str) -> str: i, j, carry = len(a) - 1, len(b) - 1, 阅读全文

posted @ 2020-01-21 03:06 codingEskimo 阅读(106) 评论(0) 推荐(0)

[LeetCode] 344.Reverse String
摘要:这道题非常简单,就是双指针问题的基础版,时间复杂度是O(N),空间复杂度是O(1) class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place 阅读全文

posted @ 2020-01-21 03:01 codingEskimo 阅读(85) 评论(0) 推荐(0)

[LeetCode] 54. Spiral Matrix
摘要:这道题的时间复杂度是O(N), 空间复杂度也是O(N) 这道题也是matrix的遍历,只是遍历的顺序是sprial,这种题的模版就是写出变化的delta,然后check新的点是不是在matrix的范围内,加上其他条件,这道题的条件是是否已经visit过,当满足就会发生一些变化,比如方向的变化。还有一 阅读全文

posted @ 2020-01-15 01:44 codingEskimo 阅读(106) 评论(0) 推荐(0)

上一页 1 2 3 下一页

导航