摘要: 242.有效的字母异位词**349. 两个数组的交集202. 快乐数1. 两数之和** 242.有效的字母异位词 题目链接 : 242. 有效的字母异位词 - 力扣(LeetCode) 代码 : class Solution {public: bool isAnagram(string s, str 阅读全文
posted @ 2024-06-28 11:09 晴夜空 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 24. 两两交换链表中的节点**19.删除链表的倒数第N个节点面试题 02.07. 链表相交142.环形链表II** 24. 两两交换链表中的节点 题目地址 : 24. 两两交换链表中的节点 - 力扣(LeetCode) Code : /** * Definition for singly-link 阅读全文
posted @ 2024-06-26 01:48 晴夜空 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 203.移除链表元素**707.设计链表206.反转链表** 203.移除链表元素 题目地址 : https://leetcode.cn/problems/remove-linked-list-elements/submissions/541762363/ 代码 : /** * Definition 阅读全文
posted @ 2024-06-25 02:03 晴夜空 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 977.有序数组的平方 ,209.长度最小的子数组 ,59.螺旋矩阵II 977.有序数组的平方 题目链接 : 977. 有序数组的平方 - 力扣(LeetCode) 代码 : class Solution {public: vector<int> sortedSquares(vector<int> 阅读全文
posted @ 2024-06-22 23:26 晴夜空 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 704. 二分查找 题目链接:https://leetcode.cn/problems/binary-search/ 前置条件:数值有序 效果:可以将 时间复杂度 优化 为 log(n) 思路: target (可能 存在 的 )元素 等于 mid 位 元素 时 , 返回 当前 下标 target 阅读全文
posted @ 2024-06-21 21:21 晴夜空 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 第六章 二叉树**part01** 递归遍历 144. 二叉树的前序遍历 Code : /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *righ 阅读全文
posted @ 2023-12-15 21:37 晴夜空 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 第五章 栈与队列**part02** 20. 有效的括号 Code : class Solution {public: bool isValid(string s) { stack<char> stack_Symbol ; // (what we really need do Now ) , 现在 阅读全文
posted @ 2023-12-09 20:32 晴夜空 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 第五章 栈与队列part01 232.用栈实现队列 基础逻辑 (用于 理解 , 直接 运行 的 话 会 报错 ,C++ STL stack 定义 的 不太一样) : 注 : //C++ STL Stack 的 pop 还 不管 弹数 , 得 用 top() 拿 逻辑 Code : class MyQ 阅读全文
posted @ 2023-12-09 19:00 晴夜空 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 第四章 字符串**part02** 28.找出字符串中第一个匹配项的下标 题目 链接 : https://leetcode.cn/problems/find-the-index-of-the-first-occurrence-in-a-string/ 暴力法 Code : class Solutio 阅读全文
posted @ 2023-12-08 18:08 晴夜空 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 第四章 字符串part01 344.反转字符串 Code : class Solution {public: void reverseString(vector<char>& s) {? int len = s.size();? int i = 0; ? int j = len - 1 ;??? w 阅读全文
posted @ 2023-12-07 17:43 晴夜空 阅读(4) 评论(0) 推荐(0) 编辑