文章分类 -  算法

java实现
摘要:后缀表达式:运算符在两个运算数后 阅读全文
posted @ 2023-11-19 20:25 44556677 阅读(12) 评论(0) 推荐(0)
摘要:/* 如果将链表的尾部作为栈顶,那么每次进行入栈和出栈操作都需要遍历链表找到尾部,这样的时间复杂度是 O(n),其中 n 是链表的长度。 而将链表的头部作为栈顶,则可以在常量时间内完成插入和删除操作,因为只需调整链表头的指针即可,时间复杂度为 O(1)。 */ //与顺序表的链式存储不同,其头结点表 阅读全文
posted @ 2023-11-19 15:09 44556677 阅读(5) 评论(0) 推荐(0)
摘要:#include<iostream> using namespace std; const int MAX=100; template <typename T> class SeqList { private: T data[MAX]; int list;//指向最后一个元素的位置 public: 阅读全文
posted @ 2023-11-19 15:08 44556677 阅读(8) 评论(0) 推荐(0)
摘要://滑动窗口 int lengthOfLongestSubstring(char * s) { int len ,i,r,l,max; r = l =max = 0; //r-->右 l-->左; while(s[r]) {//当右指针指向的字符存在时,即没有结束滑动 for(i = l; i< r 阅读全文
posted @ 2023-10-24 21:09 44556677 阅读(9) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ //进位 //改善-->直接在原链表上加:将短链表的值加到新链表上 struct List 阅读全文
posted @ 2023-10-24 21:07 44556677 阅读(157) 评论(0) 推荐(0)
摘要://哈希表 typedef struct//自定义哈希表的结构 { int key; int val; UT_hash_handle hh;//初始化为NULL } hashTable; int* twoSum(int* nums, int numsSize, int target, int* re 阅读全文
posted @ 2023-10-24 21:05 44556677 阅读(11) 评论(0) 推荐(0)