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  |  阅读:36
楊輝三角的算法,leetcode 楊輝三角 III
I 不要用排列組合,會導致溢出 class Solution { public:vector<vector<int> > generate(int numRows){ vector<int>v1;vector<vector<int> >v;for(int i=0;i<numRows;i++){ v1.clear();for(int j=0;j<=i;j&#
时间:2023-12-07  |  阅读:24
in_top_k,LeetCode 25 Reverse Nodes in k-Group Add to List (劃分list為k組)
題目鏈接:?https://leetcode.com/problems/reverse-nodes-in-k-group/?tab=Description Problem :將一個有序list劃分為k個組,并且每個組的元素逆置 鏈表操作 :遞歸算法? 每次尋找到該組的尾部,然后進行逆置操作,返回頭部
时间:2023-11-19  |  阅读:28
leetcode 53,[LeetCode] 342. Power of Four(位操作)
傳送門 Description Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Given num = 16, return true. Given num = 5, return false. Follow up: Could you solve it without loops/recursion? 思路 題意:不
时间:2023-11-19  |  阅读:30
leetcode 53,LeetCode(9)Palindrome Number
題目如下: Python代碼: def isPalindrome(self, x):""":type x: int:rtype: bool"""if(x>=0):s = int(str(x)[::-1])if(x==s):return Trueelse:return Falseelse:return False leetcode 53?? 轉載于:https://www.c
时间:2023-11-19  |  阅读:28
leetcode124,[leetcode]5341. 最后 K 個數的乘積
隨便寫下暴力就過了,美版也是 class ProductOfNumbers {vector<int>nums; public:ProductOfNumbers() {}void add(int num) {nums.push_back(num);}int getProduct(int k) {typedef long long ll;ll res = 1;for(int i = nums.size() - k; i < nums.
时间:2023-11-18  |  阅读:22
面面相交求交線,LeetCode 1035 不相交的線
?題目鏈接:力扣 面面相交求交線。問題轉換為求最長公共子序列問題: 代碼: class Solution { public:int maxUncrossedLines(vector<int>& nums1, vector<int>& nums2) { vector<vector<int>>dp(nums1.size()+1,vec
时间:2023-11-18  |  阅读:25
leetcode84,LeetCode(59):螺旋矩陣 II
Medium! leetcode84、題目描述: 給定一個正整數?n,生成一個包含 1 到?n2?所有元素,且元素按順時針順序螺旋排列的正方形矩陣。 螺旋矩陣 java?示例: 輸入: 3 輸出: [[ 1, 2, 3 ],[ 8, 9, 4 ],[ 7, 6, 5 ] ] 解題思路: 共軛矩陣?此題跟之
时间:2023-11-05  |  阅读:25
leetcode 340,leetcode-680-Valid Palindrome II
題目描述: Given a non-empty string?s, you may delete?at most?one character. Judge whether you can make it a palindrome. leetcode 340?Example 1: Input: "aba" Output: True ? Example 2: Input: "abca" Output: True Explanation: You coul
时间:2023-10-30  |  阅读:29
leetcode 53,LeetCode 3 Longest Substring Without Repeating Characters  區間,想法 難度:
https://leetcode.com/problems/longest-substring-without-repeating-characters/ 思路:從某點結束所能取到的最早開頭是到目前出現倒數第二次的字符的最末位置后一位 如圖:(S代表起點,T代表終點) abcabcab **S*T leetcode 53。假設現在在4位,向前找,a出現的倒數第二次在0位,
时间:2023-10-21  |  阅读:24

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

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

底部版权信息