随笔分类 -  LeetCode

29. 两数相除
摘要:class Solution { public: int divide(int dividend, int divisor) { // 处理特殊情况 if (divisor == 1) return dividend; if (divisor == -1) { if (dividend == INT 阅读全文

posted @ 2025-03-12 15:11 TMatrix52 阅读(9) 评论(0) 推荐(0)

LCR 105. 岛屿的最大面积
摘要:https://leetcode.cn/problems/ZL6zAn/ class Solution { public: void DFS(vector<vector<int>>& grid, int i, int j, int M, int N, int& sum) { if (grid[i][ 阅读全文

posted @ 2025-03-12 11:18 TMatrix52 阅读(11) 评论(0) 推荐(0)

27. 移除元素
摘要:int removeElement(vector<int>& nums, int val) { int slow = 0; for (int fast = 0; fast < nums.size(); ++fast) { if (nums[fast] != val) { nums[slow++] = 阅读全文

posted @ 2025-03-11 17:38 TMatrix52 阅读(8) 评论(0) 推荐(0)

21. 合并两个有序链表
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文

posted @ 2025-03-11 16:44 TMatrix52 阅读(12) 评论(0) 推荐(0)

详解二分查找算法 && leetcode35. 搜索插入位置
摘要:https://blog.csdn.net/weixin_39126199/article/details/118785065 https://leetcode.cn/problems/search-insert-position/ class Solution { public: int sear 阅读全文

posted @ 2022-08-14 22:29 TMatrix52 阅读(30) 评论(0) 推荐(0)

[LeetCode] 43. Multiply Strings 字符串相乘
摘要:[LeetCode] 43. Multiply Strings 字符串相乘 #coding=utf8 def cal_str(str1, str2): num1_len = len(str1) num2_len = len(str2) #l1存较小的 l1 = '' l2 = '' if num1_ 阅读全文

posted @ 2020-05-16 16:25 TMatrix52 阅读(145) 评论(0) 推荐(0)

导航