leetcode136,Leetcode639. Decode Ways II
題目: A message containing letters from A-Z is being encoded to numbers using the following mapping way: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Beyond that, now the encoded string can also contain the character ‘*’, whic
时间:2023-12-25  |  阅读:35
LEETCODE,[LeetCode]Link List Cycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 思考:快慢指針,快指針一次走兩步,慢指針一次一步。若快指針跟慢指針指向同一個結點,則有環。若快指針到達鏈表末尾即指向NULL
时间:2023-12-06  |  阅读:37
leetcode 課程表,leetcode Course Schedule II
題目連接 https://leetcode.com/problems/course-schedule-ii/?? Course Schedule II Description There are a total of n courses you have to take, labeled from 0 to n - 1. leetcode 課程表?Some courses may have prerequisites, for example to take course 0 you ha
时间:2023-12-06  |  阅读:39
python求中位數,leetcode 兩個排序的中位數 python
兩個排序數組的中位數 ? ? 給定兩個大小為 m 和 n 的有序數組?nums1?和?nums2?。 請找出這兩個有序數組的中位數。要求算法的時間復雜度為?O(log (m+n)) 。 你可以假設?nums1?和?nums2?不同時為空。 示例 1: nums1 = [1, 3] nums2 = [2]中位數是 2.0 python求中位
时间:2023-12-06  |  阅读:26
LeetCode,[LeetCode][JavaScript]Palindrome Linked List
Palindrome Linked List Given a singly linked list, determine if it is a palindrome. Follow up:Could you do it in O(n) time and O(1) space? https://leetcode.com/problems/palindrome-linked-list/ ? LeetCode。? ? ? 判斷單鏈表是否為回文,要求時間復雜度O
时间:2023-11-19  |  阅读:30
leetcode15,leetcode978. Longest Turbulent Subarray
題目鏈接 題目:當 A 的子數組 A[i], A[i+1], …, A[j] 滿足下列條件時,我們稱其為湍流子數組: 若 i <= k < j,當 k 為奇數時, A[k] > A[k+1],且當 k 為偶數時,A[k] < A[k+1]; 或 若 i &
时间:2023-10-21  |  阅读:29
leetCode,leetcode Longest Consecutive Sequence
#include <iostream> #include <vector> #include <unordered_map>// 時間復雜度是O(n), 空間復雜度O(n) using namespace std;class Solution1 { public:int longestConsecutive(const vector<int> &nums){unordered_map<int, bool> used;
时间:2023-10-18  |  阅读:26
leetcode15,[LeetCode] 159. Longest Substring with At Most Two Distinct Character
Given a string S, find the length of the longest substring T that contains at most two distinct characters.For example,Given S = "eceba",T is "ece" which its length is 3. 給一個字符串,找出最多有兩個不同字符的最長子串。還是滑動窗
时间:2023-10-18  |  阅读:23
leetcode 53,leetcode力扣75. 顏色分類
給定一個包含紅色、白色和藍色,一共?n 個元素的數組,原地對它們進行排序,使得相同顏色的元素相鄰,并按照紅色、白色、藍色順序排列。 此題中,我們使用整數 0、?1 和 2 分別表示紅色、白色和藍色。 leetcode 53?注意: 不能使用代碼庫中的排
时间:2023-10-11  |  阅读:25
關于網格路徑的算法,LeetCode 5366. 檢查網格中是否存在有效路徑
5366. 檢查網格中是否存在有效路徑 思路:分好上下左右的情況即可,比bfs,dfs那些簡單一點。從0,0開始,走到m-1,n-1就返回true,go_next(判斷下一步) class Solution { public:bool hasValidPath(vector<vector<int>>&
时间:2023-10-08  |  阅读:27

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息