text stringlengths 1 24.5M |
|---|
/*
* @lc app=leetcode.cn id=100 lang=cpp
*
* [100] 相åŒçš„æ ‘
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullpt... |
/*
* @lc app=leetcode.cn id=1003 lang=cpp
*
* [1003] 检查替æ¢åŽçš„è¯æ˜¯å¦æœ‰æ•ˆ
*/
// @lc code=start
class Solution {
public:
bool isValid(string s) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=101 lang=cpp
*
* [101] å¯¹ç§°äºŒå‰æ ‘
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nul... |
/*
* @lc app=leetcode.cn id=1019 lang=cpp
*
* [1019] 链表ä¸çš„下一个更大节点
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
int stk[10005],top=... |
/*
* @lc app=leetcode.cn id=1019 lang=cpp
*
* [1019] 链表ä¸çš„下一个更大节点
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
vector<int> nextLar... |
/*
* @lc app=leetcode.cn id=102 lang=cpp
*
* [102] äºŒå‰æ ‘的层åºé历
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), le... |
/*
* @lc app=leetcode.cn id=1023 lang=cpp
*
* [1023] 驼峰å¼åŒ¹é…
*/
// @lc code=start
class Solution {
public:
vector<bool> camelMatch(vector<string>& queries, string pattern) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1032 lang=cpp
*
* [1032] å—符æµ
*/
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;
// @lc code=start
class StreamChecker {
struct Node {
bool isEnd = false;
Node *next[26];
} *root;
int ar[200... |
/*
* @lc app=leetcode.cn id=104 lang=cpp
*
* [104] äºŒå‰æ ‘的最大深度
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x),... |
/*
* @lc app=leetcode.cn id=1046 lang=cpp
*
* [1046] 最åŽä¸€å—石头的é‡é‡
*/
#include <queue>
using namespace std;
// @lc code=start
class Solution {
public:
int lastStoneWeight(vector<int>& stones) {
priority_queue<int> q;
for(auto v: stones){
q.emplace(v);
}
whi... |
/*
* @lc app=leetcode.cn id=1054 lang=cpp
*
* [1054] è·ç¦»ç›¸ç‰çš„æ¡å½¢ç
*/
// @lc code=start
class Solution {
public:
vector<int> rearrangeBarcodes(vector<int>& barcodes) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=108 lang=cpp
*
* [108] å°†æœ‰åºæ•°ç»„转æ¢ä¸ºäºŒå‰æœç´¢æ ‘
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int ... |
/*
* @lc app=leetcode.cn id=109 lang=cpp
*
* [109] 有åºé“¾è¡¨è½¬æ¢äºŒå‰æœç´¢æ ‘
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(... |
/*
* @lc app=leetcode.cn id=1096 lang=cpp
*
* [1096] 花括å·å±•å¼€ II
*/
// @lc code=start
class Solution {
public:
vector<string> braceExpansionII(string expression) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=110 lang=cpp
*
* [110] å¹³è¡¡äºŒå‰æ ‘
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nul... |
/*
* @lc app=leetcode.cn id=1106 lang=cpp
*
* [1106] è§£æžå¸ƒå°”表达å¼
*/
// @lc code=start
class Solution {
public:
bool parseBoolExpr(string expression) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=111 lang=cpp
*
* [111] äºŒå‰æ ‘çš„æœ€å°æ·±åº¦
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), ... |
/*
* @lc app=leetcode.cn id=112 lang=cpp
* 1
* 2 null
* 3
* [112] 路径总和
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : ... |
/*
* @lc app=leetcode.cn id=1124 lang=cpp
*
* [1124] 表现良好的最长时间段
*/
// @lc code=start
class Solution {
public:
int longestWPI(vector<int>& hours) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=113 lang=cpp
*
* [113] 路径总和 II
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nu... |
/*
* @lc app=leetcode.cn id=1130 lang=cpp
*
* [1130] å¶å€¼çš„æœ€å°ä»£ä»·ç”Ÿæˆæ ‘
*/
// @lc code=start
class Solution {
public:
int mctFromLeafValues(vector<int>& arr) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1137 lang=cpp
*
* [1137] 第 N 个泰波那契数
*/
// @lc code=start
class Solution {
public:
int tribonacci(int n) {
int f[n+10];
f[0] = 0;
f[1] = 1;
f[2] = 1;
for(int i=3; i<=n; i++){
f[i] = f[i-1]+f[i-2]+f[i-3];
}
... |
/*
* @lc app=leetcode.cn id=114 lang=cpp
*
* [114] äºŒå‰æ ‘展开为链表
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x),... |
/*
* @lc app=leetcode.cn id=1145 lang=cpp
*
* [1145] äºŒå‰æ ‘ç€è‰²æ¸¸æˆ
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
... |
/*
* @lc app=leetcode.cn id=1155 lang=cpp
*
* [1155] 掷骰åçš„Nç§æ–¹æ³•
*/
// @lc code=start
class Solution {
public:
int numRollsToTarget(int d, int f, int target) {
int mod = 1000000007;
int dp[31][1001];
memset(dp, 0, sizeof(dp));
// 边界起点åˆå§‹åŒ–
// i表示... |
/*
* @lc app=leetcode.cn id=1157 lang=cpp
*
* [1157] åæ•°ç»„ä¸å ç»å¤§å¤šæ•°çš„å…ƒç´
*/
// @lc code=start
class MajorityChecker {
public:
MajorityChecker(vector<int>& arr) {
}
int query(int left, int right, int threshold) {
}
};
/**
* Your MajorityChecker object will be instantiated and ... |
/*
* @lc app=leetcode.cn id=116 lang=cpp
*
* [116] å¡«å……æ¯ä¸ªèŠ‚ç‚¹çš„ä¸‹ä¸€ä¸ªå³ä¾§èŠ‚ç‚¹æŒ‡é’ˆ
*/
// @lc code=start
/*
// Definition for a Node.
class Node {
public:
int val;
Node* left;
Node* right;
Node* next;
Node() : val(0), left(NULL), right(NULL), next(NULL) {}
Node(int _val) : v... |
/*
* @lc app=leetcode.cn id=1160 lang=cpp
*
* [1160] 拼写å•è¯
*/
// @lc code=start
class Solution {
public:
int countCharacters(vector<string>& words, string chars) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1161 lang=cpp
*
* [1161] æœ€å¤§å±‚å†…å…ƒç´ å’Œ
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x),... |
/*
* @lc app=leetcode.cn id=1163 lang=cpp
*
* [1163] 按å—å…¸åºæŽ’åœ¨æœ€åŽçš„å串
*/
// @lc code=start
class Solution {
public:
string lastSubstring(string s) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=117 lang=cpp
*
* [117] å¡«å……æ¯ä¸ªèŠ‚ç‚¹çš„ä¸‹ä¸€ä¸ªå³ä¾§èŠ‚ç‚¹æŒ‡é’ˆ II
*/
// @lc code=start
/*
// Definition for a Node.
class Node {
public:
int val;
Node* left;
Node* right;
Node* next;
Node() : val(0), left(NULL), right(NULL), next(NULL) {}
Node(int _val) ... |
/*
* @lc app=leetcode.cn id=1171 lang=cpp
*
* [1171] 从链表ä¸åˆ 去总和值为零的连ç»èŠ‚ç‚¹
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
//è¿... |
/*
* @lc app=leetcode.cn id=118 lang=cpp
*
* [118] æ¨è¾‰ä¸‰è§’
*/
#include <vector>
using namespace std;
// @lc code=start
class Solution {
public:
vector<vector<int>> generate(int n) {
vector<vector<int>> f(n, vector<int>(0, 0));
f[0] = {1};
for(int i=1; i<n; i++){
for(in... |
/*
* @lc app=leetcode.cn id=1190 lang=cpp
*
* [1190] å转æ¯å¯¹æ‹¬å·é—´çš„å串
*/
// @lc code=start
class Solution {
public:
string reverseParentheses(string s) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=12 lang=cpp
*
* [12] 整数转罗马数å—
*/
// @lc code=start
class Solution {
public:
string intToRoman(int num) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=120 lang=cpp
*
* [120] 三角形最å°è·¯å¾„å’Œ
*/
#include <vector>
using namespace std;
// @lc code=start
class Solution {
public:
int minimumTotal(vector<vector<int>>& t) {
int m = t.size();
if(m == 1){
return t[0][0];
}
int f[m][m];
... |
/*
* @lc app=leetcode.cn id=1209 lang=cpp
*
* [1209] åˆ é™¤å—符串ä¸çš„æ‰€æœ‰ç›¸é‚»é‡å¤é¡¹ II
*/
// @lc code=start
class Solution {
public:
string removeDuplicates(string s, int k) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=121 lang=cpp
*
* [121] ä¹°å–股票的最佳时机
*/
// @lc code=start
class Solution {
public:
int maxProfit(vector<int>& prices) {
int n = prices.size();
int f[n];
f[0] = 0;
// 记录一个当å‰çš„æœ€å°å€¼
int mi = prices[0];
for(in... |
/*
* @lc app=leetcode.cn id=122 lang=cpp
*
* [122] ä¹°å–股票的最佳时机 II
*/
// @lc code=start
class Solution {
public:
int maxProfit(vector<int>& prices) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1232 lang=cpp
*
* [1232] 缀点æˆçº¿
*/
// @lc code=start
class Solution {
public:
bool checkStraightLine(vector<vector<int>>& coordinates) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1249 lang=cpp
*
* [1249] ç§»é™¤æ— æ•ˆçš„æ‹¬å·
*/
// @lc code=start
class Solution {
public:
string minRemoveToMakeValid(string s) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=125 lang=cpp
*
* [125] 验è¯å›žæ–‡ä¸²
*/
// @lc code=start
class Solution {
public:
bool isPalindrome(string s) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=126 lang=cpp
*
* [126] å•è¯æŽ¥é¾™ II
*/
// @lc code=start
class Solution {
public:
vector<vector<string>> findLadders(string beginWord, string endWord, vector<string>& wordList) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1261 lang=cpp
*
* [1261] åœ¨å—æ±¡æŸ“çš„äºŒå‰æ ‘䏿Ÿ¥æ‰¾å…ƒç´
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class F... |
/*
* @lc app=leetcode.cn id=1266 lang=cpp
*
* [1266] è®¿é—®æ‰€æœ‰ç‚¹çš„æœ€å°æ—¶é—´
*/
// @lc code=start
class Solution {
public:
int minTimeToVisitAllPoints(vector<vector<int>>& points) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1288 lang=cpp
*
* [1288] åˆ é™¤è¢«è¦†ç›–åŒºé—´
*/
// @lc code=start
class Solution {
public:
int removeCoveredIntervals(vector<vector<int>>& intervals) {
// 从左到å³ï¼Œå·¦è¾¹ç›¸ç‰å–较大值
sort(begin(intervals), end(intervals),
[](const vector<int> &o1, const v... |
/*
* @lc app=leetcode.cn id=1289 lang=cpp
*
* [1289] 下é™è·¯å¾„最å°å’Œ II
*/
#include <vector>
using namespace std;
// @lc code=start
class Solution {
public:
int minFallingPathSum(vector<vector<int>>& g) {
int n=g.size();
int f[n][n];
for(int j=0; j<n; j++){
f[... |
/*
* @lc app=leetcode.cn id=129 lang=cpp
*
* [129] æ±‚æ ¹åˆ°å¶å节点数å—之和
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) :... |
/*
* @lc app=leetcode.cn id=1290 lang=cpp
*
* [1290] 二进制链表转整数
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
int getDecimalValue(ListNode... |
/*
* @lc app=leetcode.cn id=13 lang=cpp
*
* [13] 罗马数å—转整数
*/
// @lc code=start
class Solution {
public:
int romanToInt(string s) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=130 lang=cpp
*
* [130] 被围绕的区域
*/
// @lc code=start
class Solution {
public:
void solve(vector<vector<char>>& board) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1301 lang=cpp
* E 1 1
* X X X
* 1 1 S
*
* ["E11","XXX","11S"]
* [1301] 最大得分的路径数目
*/
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
// @lc code=start
class Solution {
public:
vector<int> pathsWithMaxScore(vector<string>& board) {... |
/*
* @lc app=leetcode.cn id=1302 lang=cpp
*
* [1302] 层数最深å¶å节点的和
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {... |
/*
* @lc app=leetcode.cn id=1305 lang=cpp
*
* [1305] ä¸¤æ£µäºŒå‰æœç´¢æ ‘ä¸çš„æ‰€æœ‰å…ƒç´
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class S... |
/*
* @lc app=leetcode.cn id=1315 lang=cpp
*
* [1315] ç¥–çˆ¶èŠ‚ç‚¹å€¼ä¸ºå¶æ•°çš„节点和
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Sol... |
/*
* @lc app=leetcode.cn id=1316 lang=cpp
*
* [1316] ä¸åŒçš„循环åå—符串
*/
// @lc code=start
class Solution {
public:
int distinctEchoSubstrings(string text) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1353 lang=cpp
*
* [1353] 最多å¯ä»¥å‚åŠ çš„ä¼šè®®æ•°ç›®
*/
// @lc code=start
class Solution {
public:
int maxEvents(vector<vector<int>>& events) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1367 lang=cpp
*
* [1367] äºŒå‰æ ‘ä¸çš„列表
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ... |
/*
* @lc app=leetcode.cn id=1372 lang=cpp
*
* [1372] äºŒå‰æ ‘ä¸çš„æœ€é•¿äº¤é”™è·¯å¾„
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Soluti... |
/*
* @lc app=leetcode.cn id=1379 lang=cpp
*
* [1379] æ‰¾å‡ºå…‹éš†äºŒå‰æ ‘ä¸çš„相åŒèŠ‚ç‚¹
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class ... |
/*
* @lc app=leetcode.cn id=138 lang=cpp
*
* [138] å¤åˆ¶å¸¦éšæœºæŒ‡é’ˆçš„é“¾è¡¨
*/
// @lc code=start
/*
// Definition for a Node.
class Node {
public:
int val;
Node* next;
Node* random;
Node(int _val) {
val = _val;
next = NULL;
random = NULL;
}
};
*/
class Solution... |
/*
* @lc app=leetcode.cn id=1381 lang=cpp
*
* [1381] 设计一个支æŒå¢žé‡æ“ä½œçš„æ ˆ
*/
// @lc code=start
class CustomStack {
public:
CustomStack(int maxSize) {
}
void push(int x) {
}
int pop() {
}
void increment(int k, int val) {
... |
/*
* @lc app=leetcode.cn id=1392 lang=cpp
*
* [1392] 最长快ä¹å‰ç¼€
*/
// @lc code=start
class Solution {
public:
string longestPrefix(string s) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=14 lang=cpp
*
* [14] 最长公共å‰ç¼€
*/
// @lc code=start
class Solution {
public:
string longestCommonPrefix(vector<string>& strs) {
for(auto s: strs){
}
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1401 lang=cpp
*
* [1401] åœ†å’ŒçŸ©å½¢æ˜¯å¦æœ‰é‡å
*/
// @lc code=start
class Solution {
public:
bool checkOverlap(int radius, int x_center, int y_center, int x1, int y1, int x2, int y2) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=141 lang=cpp
*
* [141] 环形链表
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
bool hasCycle(ListNode *head) {
if... |
/*
* @lc app=leetcode.cn id=1410 lang=cpp
*
* [1410] HTML 实体解æžå™¨
*/
// @lc code=start
class Solution {
public:
string entityParser(string text) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=142 lang=cpp
*
* [142] 环形链表 II
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNod... |
/*
* @lc app=leetcode.cn id=143 lang=cpp
*
* [143] é‡æŽ’é“¾è¡¨
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *n... |
/*
* @lc app=leetcode.cn id=1439 lang=cpp
*
* [1439] 有åºçŸ©é˜µä¸çš„第 k ä¸ªæœ€å°æ•°ç»„å’Œ
*/
// @lc code=start
class Solution {
public:
int kthSmallest(vector<vector<int>>& mat, int k) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=144 lang=cpp
*
* [144] äºŒå‰æ ‘çš„å‰åºé历
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), lef... |
/*
* @lc app=leetcode.cn id=1443 lang=cpp
*
* [1443] æ”¶é›†æ ‘ä¸Šæ‰€æœ‰è‹¹æžœçš„æœ€å°‘æ—¶é—´
*/
// @lc code=start
class Solution {
public:
int minTime(int n, vector<vector<int>>& edges, vector<bool>& hasApple) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1448 lang=cpp
*
* [1448] ç»Ÿè®¡äºŒå‰æ ‘ä¸å¥½èŠ‚ç‚¹çš„æ•°ç›®
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(in... |
/*
* @lc app=leetcode.cn id=1449 lang=cpp
*
* [1449] æ•°ä½æˆæœ¬å’Œä¸ºç›®æ ‡å€¼çš„æœ€å¤§æ•°å—
*/
// @lc code=start
class Solution {
public:
string largestNumber(vector<int>& cost, int target) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=145 lang=cpp
*
* [145] äºŒå‰æ ‘çš„åŽåºé历
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), lef... |
/*
* @lc app=leetcode.cn id=1453 lang=cpp
*
* [1453] 圆形é¶å†…的最大飞镖数é‡
*/
// @lc code=start
class Solution {
public:
int numPoints(vector<vector<int>>& points, int r) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1457 lang=cpp
*
* [1457] äºŒå‰æ ‘ä¸çš„伪回文路径
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) :... |
/*
* @lc app=leetcode.cn id=1466 lang=cpp
*
* [1466] 釿–°è§„划路线
*/
// @lc code=start
class Solution {
public:
int minReorder(int n, vector<vector<int>>& connections) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=147 lang=cpp
*
* [147] 对链表进行æ’入排åº
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int ... |
/*
* @lc app=leetcode.cn id=148 lang=cpp
*
* [148] 排åºé“¾è¡¨
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *n... |
/*
* @lc app=leetcode.cn id=150 lang=cpp
*
* [150] é€†æ³¢å…°è¡¨è¾¾å¼æ±‚值
*/
// @lc code=start
class Solution {
public:
int evalRPN(vector<string>& tokens) {
stack<int> stk;
int n = tokens.size();
for (int i = 0; i < n; i++) {
string& token = tokens[i];
if (isNu... |
/*
* @lc app=leetcode.cn id=1515 lang=cpp
*
* [1515] æœåŠ¡ä¸å¿ƒçš„æœ€ä½³ä½ç½®
*/
// @lc code=start
class Solution {
public:
double getMinDistSum(vector<vector<int>>& positions) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1521 lang=cpp
*
* [1521] æ‰¾åˆ°æœ€æŽ¥è¿‘ç›®æ ‡å€¼çš„å‡½æ•°å€¼
*/
// @lc code=start
class Solution {
public:
int closestToTarget(vector<int>& arr, int target) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1526 lang=cpp
*
* [1526] å½¢æˆç›®æ ‡æ•°ç»„çš„åæ•°ç»„æœ€å°‘å¢žåŠ æ¬¡æ•°
*/
// @lc code=start
class Solution {
public:
int minNumberOperations(vector<int>& target) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1530 lang=cpp
*
* [1530] 好å¶å节点对的数é‡
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(... |
/*
* @lc app=leetcode.cn id=154 lang=cpp
*
* [154] å¯»æ‰¾æ—‹è½¬æŽ’åºæ•°ç»„ä¸çš„æœ€å°å€¼ II
*/
// @lc code=start
class Solution {
public:
int findMin(vector<int>& nums) {
int low = 0;
int high = nums.size() - 1;
while (low < high) {
int m = low + (high - low) / 2;
... |
/*
* @lc app=leetcode.cn id=1541 lang=cpp
*
* [1541] 平衡括å·å—符串的最少æ’入次数
*/
// @lc code=start
class Solution {
public:
int minInsertions(string s) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1542 lang=cpp
*
* [1542] 找出最长的超赞åå—符串
*/
// @lc code=start
class Solution {
public:
int longestAwesome(string s) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1544 lang=cpp
*
* [1544] æ•´ç†å—符串
*/
// @lc code=start
class Solution {
public:
string makeGood(string s) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=155 lang=cpp
*
* [155] æœ€å°æ ˆ
*/
// @lc code=start
class MinStack {
public:
/** initialize your data structure here. */
MinStack() {
}
void push(int x) {
}
void pop() {
}
int top() {
}
int getMin() {
}
};
/**
* You... |
/*
* @lc app=leetcode.cn id=1585 lang=cpp
*
* [1585] 检查å—符串是å¦å¯ä»¥é€šè¿‡æŽ’åºåå—符串得到å¦ä¸€ä¸ªå—符串
*/
// @lc code=start
class Solution {
public:
bool isTransformable(string s, string t) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=160 lang=cpp
*
* [160] 相交链表
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
// æž„é€ ä¸€æ®µè·¯ç¨‹ï¼Œä½¿å¾—ä¸¤ä¸ªæŒ‡é’ˆç›¸é‡çš„æ—¶å€™èµ°è¿‡çš„è·¯ç¨... |
/*
* @lc app=leetcode.cn id=1600 lang=cpp
*
* [1600] 皇ä½ç»§æ‰¿é¡ºåº
*/
// @lc code=start
class ThroneInheritance {
public:
ThroneInheritance(string kingName) {
}
void birth(string parentName, string childName) {
}
void death(string name) {
}
vector<string> getInherit... |
/*
* @lc app=leetcode.cn id=1604 lang=cpp
*
* [1604] è¦å‘Šä¸€å°æ—¶å†…使用相åŒå‘˜å·¥å¡å¤§äºŽç‰äºŽä¸‰æ¬¡çš„人
*/
#include <algorithm>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;
// @lc code=start
class Solution {
public:
vector<string> alertNames(ve... |
/*
* @lc app=leetcode.cn id=1606 lang=cpp
*
* [1606] æ‰¾åˆ°å¤„ç†æœ€å¤šè¯·æ±‚çš„æœåС噍
*/
// @lc code=start
typedef pair<int,int> pii;
class Solution {
public:
vector<int> busiestServers(int k, vector<int>& arrival, vector<int>& load) {
int n = arrival.size();
int target = 0;
int maxSe... |
/*
* @lc app=leetcode.cn id=1609 lang=cpp
*
* [1609] 奇嶿 ‘
*/
// @lc code=start
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr... |
/*
* @lc app=leetcode.cn id=1610 lang=cpp
*
* [1610] å¯è§ç‚¹çš„æœ€å¤§æ•°ç›®
*/
// @lc code=start
class Solution {
public:
int visiblePoints(vector<vector<int>>& points, int angle, vector<int>& location) {
}
};
// @lc code=end
|
/*
* @lc app=leetcode.cn id=1638 lang=cpp
*
* [1638] 统计åªå·®ä¸€ä¸ªå—符的å串数目
*/
// @lc code=start
class Solution {
public:
int countSubstrings(string s, string t) {
int m = s.size();
int n = t.size();
int ans = 0;
for (int i = 0; i < m; ++i) {
for (int ... |
/*
* @lc app=leetcode.cn id=1641 lang=cpp
*
* [1641] 统计å—å…¸åºå…ƒéŸ³å—符串的数目
*/
// @lc code=start
class Solution
{
public:
int countVowelStrings(int n)
{
if (n == 0)
return 0;
if (n == 1)
return 5;
int ans[n + 1][5];
ans[1][0] = 1;
... |
/*
* @lc app=leetcode.cn id=1642 lang=cpp
*
* [1642] å¯ä»¥åˆ°è¾¾çš„æœ€è¿œå»ºç‘
*/
// @lc code=start
class Solution {
public:
int furthestBuilding(vector<int>& heights, int bricks, int ladders) {
int n = heights.size();
// 由于我们需è¦ç»´æŠ¤æœ€å¤§çš„ l ä¸ªå€¼ï¼Œå› æ¤ä½¿ç”¨å°æ ¹å †
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.