iT邦幫忙

leetcode相關文章
共有 943 則文章

技術 【Stone Game】LeetCode 解題 leetcode-877

Stone Game 題目連結 兩種情況 大數字在前或後==> alice 可以先選 大數字在中間 ==> 由於alice 選數字時數量一定是...

技術 【Smallest String Starting From Leaf】LeetCode 解題 (leetcode-988)

Smallest String Starting From Leaf 題目連結 用bfs來做 1.先移路往左走(直到左邊是null),刪掉當下的點(往回走)...

技術 【Add One Row to Tree】Leetcode解題 leetcode-623

Add One Row to Tree (623) 在原本的二元樹的某一層插入新節點(後面一樣是舊節點) 用bfs遍歷樹(直到到要補的層前),插入左值與右值...

技術 [LeetCode] 875 - Koko Eating Bananas

[LeetCode] 875 - Koko Eating Bananas Problem 給定一個有 n 堆香蕉的陣列 piles (第 i 堆的數量為 pil...

技術 【Cheapest Flights Within K Stops】Leetcode 解題 2/24

Cheapest Flights Within K Stops 很久沒有發文了,雖然還是有寫題的習慣,但寫解題真的有點懶(誤 總而言之,最後還是決定寫一下,畢竟...

技術 [LeetCode筆記] 34. Find First and last Position of Element in Sorted Array

前言   這題標準運用了二分搜尋法,演算法通常需要使用二分思想,即每次能夠排除一半的範圍,快速的找出陣列中所要求的元素位置,這樣時間複雜度可達 O(log n)...

技術 [leetcode - Bliend-150 ] 567. Permutation in String (Medium)

Given two strings s1 and s2, return true if s2 contains a permutation of s1, or...

技術 [leetcode - Bliend-150 ] 739. Daily Temperatures (Medium)

Given an array of integers temperatures represents the daily temperatures, retur...

技術 [leetcode - Bliend-150 ] 746. Min Cost Climbing Stairs (Easy)

You are given an integer array cost where cost[i] is the cost of ith step on a s...

技術 [leetcode - Bliend-75 ] 5. Longest Palindromic Substring (Medium)

Given a string s, return the longest palindromic substring in s. 給一個 string 回傳該...

技術 [leetcode - Bliend-75 ] 213. House Robber II (Medium)

You are a professional robber planning to rob houses along a street. Each house...

技術 [leetcode - Bliend-75 ] 198. House Robber (Medium)

You are a professional robber planning to rob houses along a street. Each house...

技術 [leetcode - Bliend-75 ] 105. Construct Binary Tree from Preorder and Inorder Traversal (Medium)

Given two integer arrays preorder and inorder where preorder is the preorder tra...

技術 [leetcode - Bliend-75 ] 226. Invert Binary Tree (Easy)

Given the root of a binary tree, invert the tree, and return its root. 給一個 tree...

技術 [leetcode - Bliend-75 ] 19. Remove Nth Node From End of List (Medium)

Given the head of a linked list, remove the nth node from the end of the list an...

技術 [leetcode - Bliend-75 ] 143. Reorder List (Medium)

You are given the head of a singly linked-list. The list can be represented as:...

技術 [leetcode - Bliend-75 ] 206. Reverse Linked List (Easy)

Given the head of a singly linked list, reverse the list, and return the reverse...

技術 [leetcode - Bliend-75 ] 21. Merge Two Sorted Lists (Easy)

You are given the heads of two sorted linked lists list1 and list2. Merge the tw...

技術 [leetcode - Bliend-75 ] 33. Search in Rotated Sorted Array (Medium)

There is an integer array nums sorted in ascending order (with distinct values)....

技術 [leetcode - Bliend-75 ] 153. Find Minimum in Rotated Sorted Array (Medium)

Suppose an array of length n sorted in ascending order is rotated between 1 and...

技術 [leetcode - Bliend-75 ] 424. Longest Repeating Character Replacement (Medium)

You are given a string s and an integer k. You can choose any character of the s...

技術 [leetcode - Bliend-75 ]3. Longest Substring Without Repeating Characters (Medium)

Given a string s, find the length of the longest substring without repeating cha...

技術 [leetcode - Bliend-75 ] 242. Valid Anagram (Easy)

Given two strings s and t, return true if t is an anagram of s, and false otherw...

技術 [leetcode - Bliend-75 ] 217. Contains Duplicate (Easy)

Given an integer array nums, return true if any value appears at least twice in...

技術 Leetcode解題技巧- 快速閱讀題目:

歐氏定理: 「英文文法跟中文相反」。以下這一段英文,最重要的是在「最後面」(choose an element of the array and increme...

技術 [LeetCode] 13. Roman to Integer

MediumRelated Topics: Hash Table / Math / StringLeetCode Source 解題想法 LeetCode...

技術 Leetcode 中文。你可能只花一分鐘寫完程式碼,但是比較困難在於閱讀英文題目。

歐氏定理: 「英文文法跟中文是相反的。」Return true if s is an acronym of words, and false otherwise...

技術 [LeetCode] 42. Trapping Rain Water

HardRelated Topics: Array / Two Pointers / Dynamic Programming / Stack / Monoto...

技術 [LeetCode 筆記] 198. House Robber

前言   這題是一題動態規劃問題,目標是擷取不連續的元素,全部相加起來選出最優解,因只用了一層迴圈,時間複雜度可估 O(n),這裡有 JAVA 和 Python...

技術 [LeetCode] 135. Candy

HardRelated Topics: Array / GreedyLeetCode Source 解題想法 首先先確認 len(ratings),如果小於...