
leetcode
文章平均质量分 65
severus-94
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
119. Pascal's Triangle II Python
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?给定k,返回第k行的杨辉三角,最好使用O(k)的空间复杂...原创 2018-03-09 15:20:47 · 294 阅读 · 0 评论 -
237. Delete Node in a Linked List(Python3)
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Given linked list -- head = [4,5,1,9], which looks like following: 4 -> 5 -> 1 ->...原创 2018-06-12 18:32:59 · 252 阅读 · 0 评论 -
235. Lowest Common Ancestor of a Binary Search Tree (Python3)
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between tw...原创 2018-06-12 18:25:14 · 320 阅读 · 0 评论 -
205. Isomorphic Strings [easy] Python3 C++
Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another char...原创 2018-05-02 18:41:27 · 177 阅读 · 0 评论 -
204. Count Primes [easy] Python3和C++
Count the number of prime numbers less than a non-negative number, n.寻找n以内的素数个数。解法一最笨的方法是遍历到n,逐个判断,Python3代码如下:class Solution: def isPrime(self, a): if a <=1: retu...原创 2018-05-01 19:14:17 · 198 阅读 · 0 评论 -
136. Single Number [medium] Python3
Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra me...原创 2018-03-10 20:21:42 · 192 阅读 · 0 评论 -
125. Valid Palindrome Python3
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a palindro...原创 2018-03-10 20:03:39 · 208 阅读 · 0 评论 -
122. Best Time to Buy and Sell Stock II Python3
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one an...原创 2018-03-10 19:52:43 · 228 阅读 · 0 评论 -
121. Best Time to Buy and Sell Stock Python3
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 (ie, buy one and sell one share of the stock), des...原创 2018-03-09 15:33:54 · 300 阅读 · 0 评论 -
242. Valid Anagram(Python3)
Given two strings s and t , write a function to determine if t is an anagram of s.Example 1:Input: s = "anagram", t = "nagaram" Output: true Example 2:Input: s = "rat", t = "car" Output: false构建哈希表就可以...原创 2018-06-12 19:04:26 · 341 阅读 · 0 评论