![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode题解
丶Axe
Life is short, I use Python.
展开
-
LeetCode *342.Power of Four (Python Solution)
题目描述Given an integer (signed 32 bits), write a function to check whether it is a power of 4.给定一个整数(带符号的32位),写一个函数来检查它是否为4的幂。Example 1:Input: 16Output: trueExample 2:Input: 5Output: false...原创 2019-08-03 00:34:38 · 113 阅读 · 0 评论 -
LeetCode *328. Odd Even Linked List (Python Solution)
题目描述Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it ...原创 2019-09-03 13:41:30 · 132 阅读 · 0 评论 -
LeetCode *24. Swap Nodes in Pairs (Python Solution)
题目描述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.给定链表,交换每两个相邻结点并返回其头部。您可能无法修改列表结点中的值,只...原创 2019-09-03 11:39:17 · 133 阅读 · 0 评论 -
LeetCode *80. Remove Duplicates from Sorted Array II (Python Solution)
题目描述Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.Do not allocate extra space for another array, you must do this by...原创 2019-08-16 17:43:01 · 82 阅读 · 0 评论 -
LeetCode *26. Remove Duplicates from Sorted Array (Python Solution)
题目描述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 mod...原创 2019-08-16 17:03:18 · 126 阅读 · 0 评论 -
LeetCode *27. Remove Element (Python Solution)
题目描述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 ...原创 2019-08-16 16:36:58 · 119 阅读 · 0 评论 -
LeetCode *206. Reverse Linked List (Python Solution)
题目描述Reverse a singly linked list.反转一个单链表Example 1:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLPython Solution分析: 反转链表是链表操作里比较经典的题型,操作为用一个单链表储存新的反转后的链表,原...原创 2019-08-19 12:41:11 · 190 阅读 · 0 评论 -
LeetCode *876. Middle of the Linked List (Python Solution)
题目描述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 middle node.给定具有头节点头的非空的单链表,返回链表的中间节点。如果有两个中间节点,...原创 2019-08-09 15:40:19 · 152 阅读 · 0 评论 -
LeetCode *203.Remove Linked List Elements (Python Solution)
题目描述Remove all elements from a linked list of integers that have value val.从链表中删除所有值等于 val 的结点ExampleInput: 1->2->6->3->4->5->6, val = 6Output: 1->2->3->4->5Pytho...原创 2019-08-09 14:51:09 · 154 阅读 · 0 评论 -
LeetCode *1.Two Sum (Python Solution)
问题描述Two Sum 原题链接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 ...原创 2019-07-22 10:01:22 · 133 阅读 · 0 评论 -
LeetCode *20.Valid Parentheses (Python Solution)
问题描述Valid Parentheses Leetcode20Given a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:1.Open brackets mu...原创 2019-07-25 18:15:44 · 156 阅读 · 0 评论 -
LeetCode *231.Power of Two (Python Solution)
题目描述Given an integer, write a function to determine if it is a power of two.给定一个整数,写一个函数来确定它是否是2的幂。Example 1:Input: 1Output: trueExplanation: 20 = 1Example 2:Input: 16Output: trueExplanat...原创 2019-08-02 14:54:42 · 219 阅读 · 0 评论 -
LeetCode *100. Same Tree (Python Solution)
题目描述Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.给定两个二...原创 2019-08-08 17:12:28 · 150 阅读 · 0 评论 -
LeetCode *19. Remove Nth Node From End of List (Python Solution)
题目描述Given a linked list, remove the n-th node from the end of list and return its head.给定一个链表,从列表末尾删除第n个节点并返回其头指针。Example 1:Input: 1Output: trueExplanation: 20 = 1Example 2:Input: 16Output...原创 2019-08-08 15:30:31 · 108 阅读 · 0 评论 -
LeetCode *226.Invert Binary Tree (Python Solution)
题目描述Invert a binary tree.操作给定的二叉树,将其变换为源二叉树的镜像。二叉树的镜像定义:源二叉树 8 / \ 6 10 / \ / \ 5 7 9 11 镜像二叉树 8 / \ 10 6 / \ / \ ...原创 2019-08-08 15:17:43 · 136 阅读 · 0 评论 -
LeetCode *92. Reverse Linked List II (Python Solution)
题目描述Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.将位置m的链接列表反转到n。 只遍历一次。注意:1≤m≤n≤列表长度。Example 1:Input: 1->2->3->4->5->NULL, m = 2,...原创 2019-09-03 16:54:14 · 147 阅读 · 0 评论