- 博客(20)
- 收藏
- 关注
原创 LeetCode091. Decode Ways python
A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given anon-emptystring containing only digits, determine t...
2019-10-29 10:59:52 113
原创 LeetCode064. Minimum Path Sum
Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:You can only move either down or right at a...
2019-10-28 22:49:15 104
原创 LeetCode063. Unique Paths II
An obstacle and empty space is marked as1and0respectively in the grid.Note:mandnwill be at most 100.Example 1:Input:[ [0,0,0], [0,1,0], [0,0,0]]Output: 2Explanation:There is ...
2019-10-28 22:35:32 91
原创 LeetCode062. Unique Paths
A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bo...
2019-10-26 15:39:52 122
原创 LeetCode098. Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keysless thanthe node's key. The ...
2019-10-24 16:57:32 80
原创 LeetCode096. Unique Binary Search Trees
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1 ...n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total of 5 unique BST's: 1 ...
2019-10-24 16:02:38 72
原创 LeetCode033. Search in Rotated Sorted Array
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 ...
2019-10-23 20:46:32 81
原创 LeetCode094. Binary Tree Inorder Traversal
Given a binary tree, return theinordertraversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]中序遍历.如果忘了的话参考https://blog.csdn.net/zl6481033/arti...
2019-10-23 20:43:53 74
原创 LeetCode148. Sort List
Sort a linked list inO(nlogn) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Output: -...
2019-10-22 21:06:59 75
原创 LeetCode143. Reorder List
Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You maynotmodify the values in the list's nodes, only nodes itself may be changed.Example 1:Given 1->2-...
2019-10-21 22:57:23 78
原创 LeetCode0138. Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return adeep copyof the list.Input:{"$id":"1","next":{"$id":"...
2019-10-17 11:57:47 105
转载 python中的None,is和==
1. NoneNone是python中的一个特殊的常量,表示一个空的对象,空值是python中的一个特殊值。数据为空并不代表是空对象,例如[],''等都不是None。None和任何对象比较返回值都是False,除了自己。>>> L=[]>>> L is NoneFalse>>> L=''>>> L is No...
2019-10-17 10:51:46 900
转载 python浅拷贝和深拷贝详解
假设有一个列表,如下:然后呢,我打印出这四个列表的内存地址:l = [1, 2, 3, 4, [1, 2, 3] ]id(l)--------------->1631063137352new_l = l...
2019-10-16 21:56:09 146
原创 LeetCode092. Reverse Linked List II
Reverse a linked list from positionmton. Do it in one-pass.Note:1 ≤m≤n≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2->5-...
2019-10-16 20:15:49 82
原创 LeetCode86. Partition List
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each of the...
2019-10-16 18:10:27 168
原创 LeetCode082. Remove Duplicates from Sorted List II
这个题卡了一会,各种报错。思路有问题,开始想到了新建一个链表进行存储,问题在于:我原来的想法是在原链表上找到符合要求那个点再添加到新链表中去。这样其实比较麻烦。新的方法先把ListNode放到新链表p后面,也就是p.next=ListNode,再判断是否符合要求(没有重复),如果符合要求,p=p.next,不断更新如果不符合要求,下一个ListNode还是放在p后面,仍然是p....
2019-10-16 16:32:11 75
原创 LeetCode061. Rotate List
用双指针找到倒数第n个ListNode的位置,也就是旋转的节点。这个题只需要注意一下记录链表长度。# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Nonecl...
2019-10-15 19:56:55 93
原创 LeetCode024. Swap Nodes in Pairs
Given alinked list, swap every two adjacent nodes and return its head.You maynotmodify the values in the list's nodes, only nodes itself may be changed.Example:Given 1->2->3->4, you...
2019-10-15 15:34:12 104
原创 LeetCode023. Merge k Sorted Lists
Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4-...
2019-10-13 23:59:13 86
原创 LeetCode019. Remove Nth Node From End of List
Given a linked list, remove then-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 end, t...
2019-10-13 22:08:18 80
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人