
leetcode
魔术师_
这个作者很懒,什么都没留下…
展开
-
001.twosum - python
题目如下Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sam...原创 2018-04-22 09:23:57 · 130 阅读 · 0 评论 -
230. Kth Smallest Element in a BST -- python
题目:Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.Follow up:What if the BST is mod...原创 2018-04-27 11:11:20 · 470 阅读 · 0 评论 -
33. Search in Rotated Sorted Array--python
题目:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a target value to search. If found i...原创 2018-04-26 17:33:40 · 569 阅读 · 0 评论 -
160. Intersection of Two Linked Lists --python
题目:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin to intersect at node c1.Notes:If the two linked lists ...原创 2018-04-26 16:10:31 · 413 阅读 · 0 评论 -
155. Min Stack -- python
题目: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 element on top of the stack.top() -- Get t...原创 2018-04-26 14:56:51 · 441 阅读 · 0 评论 -
75. Sort Colors -- python
题目:Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the i...原创 2018-04-26 14:37:23 · 539 阅读 · 0 评论 -
148. Sort List--python
题目:Sort a linked list in O(n log n) time using constant space complexity.Example 1:Input: 4->2->1->3 Output: 1->2->3->4 Example 2:Input: -1->5->3->4->0 Output: -1->0-&...原创 2018-04-26 14:14:56 · 612 阅读 · 0 评论 -
56. Merge Intervals--python
题目:解题:先将区间按照每个start的值来排序,排好序以后判断一个区间的start值是否处在前一个区间中,如果在前一个区间中,那么合并;如果不在,就将新区间添加。# Definition for an interval. # class Interval(object): # def __init__(self, s=0, e=0): # self.start = s #...原创 2018-05-03 11:28:28 · 368 阅读 · 0 评论 -
378. Kth Smallest Element in a Sorted Matrix - python
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order, not the...原创 2018-04-21 10:58:43 · 300 阅读 · 0 评论 -
94. Binary Tree Inorder Traversal--python
题目:Given a binary tree, return the inorder traversal of its nodes' values.Example:Follow up: Recursive solution is trivial, could you do it iteratively?解题:二叉树的中序遍历,可以用递归的方式(关于中序遍历可以参考我的另一篇博客,详细介绍了中序,前...原创 2018-05-02 14:53:43 · 316 阅读 · 0 评论 -
341. Flatten Nested List Iterator -- python
题目:Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers or other lists.Example 1:Given the list [[1,...原创 2018-05-02 10:21:57 · 768 阅读 · 0 评论 -
189. Rotate Array -python
题目如下Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]给定一个数组,和一个数字k,将数组末尾的数字移到开头解题class Solution: def...原创 2018-04-22 09:26:08 · 342 阅读 · 0 评论 -
19. Remove Nth Node From End of List--python
题目: Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the en...原创 2018-05-08 17:58:26 · 293 阅读 · 0 评论