上一页 1 ··· 5 6 7 8 9 10 11 12 下一页
摘要: M进制转N进制 3374. 进制转换2 #include <iostream> #include <algorithm> #include <cstring> #include <vector> using namespace std; int main() { int a, b; string s 阅读全文
posted @ 2022-08-07 21:01 Tshaxz 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 3765. 表达式树 将给定的表达式树(二叉树)转换为等价的中缀表达式(通过括号反映操作符的计算次序)并输出。 /** * Definition for a binary tree node. * struct TreeNode { * string val; * TreeNode *left; * 阅读全文
posted @ 2022-08-05 16:53 Tshaxz 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 151. 表达式计算4 写法一: #include <iostream> #include <stack> #include <unordered_map> using namespace std; stack<char> op; stack<int> num; int qmi(int a, int 阅读全文
posted @ 2022-08-05 15:42 Tshaxz 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 周赛传送门 4500. 三个元素 本题可以学习的地方: 1.用map来存值和下标,map会自动排序 2.输出map中的元素可以先用vector存起来,然后输出vector中的元素 #include <iostream> #include <map> #include <vector> using n 阅读全文
posted @ 2022-07-31 15:55 Tshaxz 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 题单:LeetCode链表 2. 两数相加 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) { 阅读全文
posted @ 2022-07-30 18:41 Tshaxz 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 记录LeetCode 热题 HOT 100 代码 1. 两数之和 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int, int> hash; for(int i 阅读全文
posted @ 2022-07-18 19:58 Tshaxz 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 62. 丑数 class Solution { public: int getUglyNumber(int n) { vector<int> q(1, 1); int i = 0, j = 0, k = 0; while( -- n) // 循环 n - 1 次 { int t = min(q[i] 阅读全文
posted @ 2022-05-17 17:43 Tshaxz 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 122. 糖果传递 写法一: #include <iostream> #include <algorithm> #include <cstring> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; L 阅读全文
posted @ 2022-05-10 13:45 Tshaxz 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 求下一个序列的考虑方法: 尽量保证地位不变,变高位。所以可以从后往前去考虑 视频讲解:LeetCode 31. 下一个排列 模板题: 31. 下一个排列 class Solution { public: void nextPermutation(vector<int>& nums) { int k 阅读全文
posted @ 2022-05-05 21:50 Tshaxz 阅读(57) 评论(0) 推荐(0) 编辑
摘要: map按value排序/自定义排序规则 sort不能直接排map,需要把map放入到vector中再对vector排序 方法如下 using PSI = pair<string, int>; vector<PSI> arr; unordered_map<string, int> mp 阅读全文
posted @ 2022-05-04 18:18 Tshaxz 阅读(42) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 下一页
Language: HTML
点击右上角即可分享
微信分享提示