摘要:
M进制转N进制 3374. 进制转换2 #include <iostream> #include <algorithm> #include <cstring> #include <vector> using namespace std; int main() { int a, b; string s 阅读全文
摘要:
3765. 表达式树 将给定的表达式树(二叉树)转换为等价的中缀表达式(通过括号反映操作符的计算次序)并输出。 /** * Definition for a binary tree node. * struct TreeNode { * string val; * TreeNode *left; * 阅读全文
摘要:
151. 表达式计算4 写法一: #include <iostream> #include <stack> #include <unordered_map> using namespace std; stack<char> op; stack<int> num; int qmi(int a, int 阅读全文
摘要:
周赛传送门 4500. 三个元素 本题可以学习的地方: 1.用map来存值和下标,map会自动排序 2.输出map中的元素可以先用vector存起来,然后输出vector中的元素 #include <iostream> #include <map> #include <vector> using n 阅读全文
摘要:
题单:LeetCode链表 2. 两数相加 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) { 阅读全文
摘要:
记录LeetCode 热题 HOT 100 代码 1. 两数之和 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int, int> hash; for(int i 阅读全文
摘要:
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] 阅读全文
摘要:
122. 糖果传递 写法一: #include <iostream> #include <algorithm> #include <cstring> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; L 阅读全文
摘要:
求下一个序列的考虑方法: 尽量保证地位不变,变高位。所以可以从后往前去考虑 视频讲解:LeetCode 31. 下一个排列 模板题: 31. 下一个排列 class Solution { public: void nextPermutation(vector<int>& nums) { int k 阅读全文
摘要:
map按value排序/自定义排序规则 不能直接排,需要把map放入到vector中再对vector排序 方法如下 using PSI = pair<string, int>; vector<PSI> arr; unordered_map<string, int> mp 阅读全文