原创 leetcode 238. Product of Array Except Self (Python版)

題目: 好長,大意是返回一個列表,列表中第i個元素爲nums中出了i以外元素的乘積 注意不能用除法,時間複雜度爲O(n) 空間複雜度爲O(1)解題思路: 利用返回的列表從前往後算一遍,再從後往前算一次即可代碼:class Solution(

原创 leetcode 238. Product of Array Except Self (Python版)

題目: 好長,大意是返回一個列表,列表中第i個元素爲nums中出了i以外元素的乘積 注意不能用除法,時間複雜度爲O(n) 空間複雜度爲O(1)解題思路: 利用返回的列表從前往後算一遍,再從後往前算一次即可代碼:class Solution(

原创 leetcode 238. Product of Array Except Self (Python版)

題目: 好長,大意是返回一個列表,列表中第i個元素爲nums中出了i以外元素的乘積 注意不能用除法,時間複雜度爲O(n) 空間複雜度爲O(1)解題思路: 利用返回的列表從前往後算一遍,再從後往前算一次即可代碼:class Solution(

原创 leetcode 241. Different Ways to Add Parentheses (Python版)

題目:Given a string of numbers and operators, return all possible results from computing all the different possible ways t

原创 leetcode 114. Flatten Binary Tree to Linked List (Python版)

題目:     Given a binary tree, flatten it to a linked list in-place.算法思路:  其實該題目就是二叉樹前序遍歷的變形  我代碼沿用leetcode 144. Binary Tr

原创 leetcode 147. Insertion Sort List (Python版)

題目:    Sort a linked list using insertion sort.    大意是要實現一個鏈表的插入排序算法思路:    從原鏈表中逐個彈出一個node    對於每一個node用插入排序的思想插入新的升序排列的

原创 leetcode 3. Longest Substring Without Repeating Characters (Python版)

題目:Given a string, find the length of the longest substring without repeating characters. For example, the longest subst