repo_name stringlengths 5 122 | path stringlengths 3 232 | text stringlengths 6 1.05M |
|---|---|---|
ooooo-youwillsee/leetcode | 1678-Goal Parser Interpretation/cpp_1678/Solution1.h | /**
* @author ooooo
* @date 2021/1/29 20:47
*/
#ifndef CPP_1678__SOLUTION1_H_
#define CPP_1678__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <numeric>
#include <queue>
using namespace std;
class Solution {
public:
string interpr... |
ooooo-youwillsee/leetcode | lcof_022/cpp_022/Solution2.h | //
// Created by ooooo on 2020/3/15.
//
#ifndef CPP_022__SOLUTION2_H_
#define CPP_022__SOLUTION2_H_
#include "ListNode.h"
class Solution {
public:
ListNode *getKthFromEnd(ListNode *head, int k) {
ListNode *dummyHead = new ListNode(0), *cur = dummyHead;
dummyHead->next = head;
// 先前走 k-1 步
for (int... |
ooooo-youwillsee/leetcode | 0844-Backspace-String-Compare/cpp_0844/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/5.
//
#ifndef CPP_0844_SOLUTION1_H
#define CPP_0844_SOLUTION1_H
#include <iostream>
#include <stack>
using namespace std;
class Solution {
public:
stack<char> help(string s) {
stack<char> ss;
for (auto c: s) {
if (c... |
ooooo-youwillsee/leetcode | 1630-Arithmetic Subarrays/cpp_1630/Solution1.h | /**
* @author ooooo
* @date 2020/11/15 09:40
*/
#ifndef CPP_1630__SOLUTION1_H_
#define CPP_1630__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
class Solution {
public:
bool isArithmeticArray(vector<int> &nums) {
if (nums.size() < 2... |
ooooo-youwillsee/leetcode | 0575-Distribute-Candies/cpp_0575/Solution2.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/12.
//
#ifndef CPP_0575__SOLUTION2_H_
#define CPP_0575__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
class Solution {
public:
int distributeCandies(vector<int> &candies) {
unordered_set<int... |
ooooo-youwillsee/leetcode | lcof_055-1/cpp_055-1/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/4/11.
//
#ifndef CPP_055_1__SOLUTION2_H_
#define CPP_055_1__SOLUTION2_H_
#include "TreeNode.h"
#include <queue>
/**
* dfs
*/
class Solution {
public:
void dfs(TreeNode *root, int level) {
if (!root) {
maxLevel = max(maxLevel, level);
return;
}
... |
ooooo-youwillsee/leetcode | 1738-Find Kth Largest XOR Coordinate Value/cpp_1738/Solution2.h | /**
* @author ooooo
* @date 2021/5/19 21:11
*/
#ifndef CPP_1738__SOLUTION2_H_
#define CPP_1738__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int kthLargestValue(vector<vector<int>> &matrix, int k) {
int m = matrix.size(), n = matrix[0].size();
vector<vec... |
ooooo-youwillsee/leetcode | 0496-Next-Greater-Element-I/cpp_0496/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/5.
//
#ifndef CPP_0496_SOLUTION2_H
#define CPP_0496_SOLUTION2_H
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_map>
using namespace std;
class Solution {
public:
vector<int> nextGreaterElement(vector<int> &nums1, vector<int> &nums2) {
... |
ooooo-youwillsee/leetcode | 0299-Bulls-and-Cows/cpp_0299/Solution2.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/10.
//
#ifndef CPP_0299__SOLUTION2_H_
#define CPP_0299__SOLUTION2_H_
#include <iostream>
#include <unordered_map>
using namespace std;
class Solution {
public:
string getHint(string secret, string guess) {
int A = 0, B = 0;
unordered_map... |
ooooo-youwillsee/leetcode | 0581-Shortest-Unsorted-Continuous-Subarray/cpp_0581/Solution2.h | //
// Created by ooooo on 2020/2/7.
//
#ifndef CPP_0581__SOLUTION2_H_
#define CPP_0581__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
/**
*
*/
class Solution {
public:
int findUnsortedSubarray(vector<int> &nums) {
int min_value = INT_MAX, max_value = INT_MIN;
for (int i = 1; i ... |
ooooo-youwillsee/leetcode | 1071-Greatest-Common-Divisor-of-Strings/cpp_1071/Solution2.h | //
// Created by ooooo on 2020/2/2.
//
#ifndef CPP_1071__SOLUTION2_H_
#define CPP_1071__SOLUTION2_H_
#include <iostream>
#include <math.h>
#include <numeric>
using namespace std;
/**
* gcd
*/
class Solution {
public:
string gcdOfStrings(string str1, string str2) {
if (str1 + str2 != str2 + str1) return "";... |
ooooo-youwillsee/leetcode | 0221-Maximal-Square/cpp_0221/Solution1.h | <filename>0221-Maximal-Square/cpp_0221/Solution1.h
//
// Created by ooooo on 2020/2/20.
//
#ifndef CPP_0221__SOLUTION1_H_
#define CPP_0221__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* dp[i][j] = min(dp[i][j-1],dp[i-1][j-1],dp[i-1][j]) + 1
*/
class Solution {
public:
int maximal... |
ooooo-youwillsee/leetcode | 1232-Check If It Is a Straight Line/cpp_1232/Solution1.h | <filename>1232-Check If It Is a Straight Line/cpp_1232/Solution1.h
/**
* @author ooooo
* @date 2021/1/17 12:19
*/
#ifndef CPP_1232__SOLUTION1_H_
#define CPP_1232__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
bool checkStraightLine(vector<vector<int>> &coordi... |
ooooo-youwillsee/leetcode | 1576-Replace-All-XLetter-to-Avoid-Consecutive-Repeating-Characters/cpp_1576/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2020/9/7 13:14
*/
#ifndef CPP_1576__SOLUTION1_H_
#define CPP_1576__SOLUTION1_H_
#include <iostream>
#include <string>
using namespace std;
class Solution {
public:
bool dfs(string &s, int i) {
if (i == s.length()) return true;
if (s[i] != '?... |
ooooo-youwillsee/leetcode | 0234-Palindrome-Linked-List/cpp_0234/Solution2.h | //
// Created by ooooo on 2020/1/8.
//
#ifndef CPP_0234_SOLUTION2_H
#define CPP_0234_SOLUTION2_H
#include "ListNode.h"
class Solution {
public:
bool isPalindrome(ListNode *head) {
if (!head || !head->next) return true;
ListNode *low = head, *fast = head, *prev = nullptr, *temp = nullptr;
... |
ooooo-youwillsee/leetcode | 0127-Word-Ladder/cpp_0127/Solution2.h | <filename>0127-Word-Ladder/cpp_0127/Solution2.h
//
// Created by ooooo on 2019/12/31.
//
#ifndef CPP_0127_SOLUTION2_H
#define CPP_0127_SOLUTION2_H
#include <iostream>
#include <string>
#include <climits>
#include <vector>
#include <unordered_set>
#include <unordered_map>
using namespace std;
class Solution {
publi... |
ooooo-youwillsee/leetcode | 0824-Goat-Latin/cpp_0824/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/31.
//
#ifndef CPP_0824__SOLUTION1_H_
#define CPP_0824__SOLUTION1_H_
#include <iostream>
using namespace std;
/**
* 拼接字符串效率低
*/
class Solution {
public:
string help(string word, int i, bool space) {
string newWord = "";
char firstChar... |
ooooo-youwillsee/leetcode | 0105-Construct-Binary-Tree-from-Preorder-and-Inorder Traversal/cpp_0105/Solution1.h | //
// Created by ooooo on 2020/2/16.
//
#ifndef CPP_0105__SOLUTION1_H_
#define CPP_0105__SOLUTION1_H_
#include "TreeNode.h"
#include <vector>
#include <unordered_map>
class Solution {
public:
TreeNode *help(int in_l, int in_r) {
if (in_l > in_r) return nullptr;
int root_value = preorder[preIndex++];
T... |
ooooo-youwillsee/leetcode | 0575-Distribute-Candies/cpp_0575/Solution1.h | //
// Created by ooooo on 2020/1/12.
//
#ifndef CPP_0575__SOLUTION1_H_
#define CPP_0575__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
class Solution {
public:
int distributeCandies(vector<int> &candies) {
unordered_map<int, int> m, a... |
ooooo-youwillsee/leetcode | 1190-Reverse Substrings Between Each Pair of Parentheses/cpp_1190/Solution1.h | /**
* @author ooooo
* @date 2021/5/26 13:25
*/
#ifndef CPP_1190__SOLUTION1_H_
#define CPP_1190__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
class Solution {
public:
string reverseParentheses(string s) {
stack<char> sk;
for (int i = 0; i < s.size(); i++) {
if... |
ooooo-youwillsee/leetcode | 0961-N-Repeated-Element-in-Size-2N-Array/cpp_0961/Solution1.h | //
// Created by ooooo on 2020/1/17.
//
#ifndef CPP_0961__SOLUTION1_H_
#define CPP_0961__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
class Solution {
public:
int repeatedNTimes(vector<int> &A) {
unordered_set<int> s;
for (auto item: A) {
if (s.cou... |
ooooo-youwillsee/leetcode | 0114-Flatten-Binary-Tree-to-Linked-List/cpp_0114/Solution3.h | //
// Created by ooooo on 2020/2/16.
//
#ifndef CPP_0114__SOLUTION3_H_
#define CPP_0114__SOLUTION3_H_
#include "TreeNode.h"
/**
* in-place
*/
class Solution {
public:
void flatten(TreeNode *root) {
while (root) {
if (!root->left) {
root = root->right;
} else {
TreeNode *prev = roo... |
ooooo-youwillsee/leetcode | 0937-Reorder-Log-File/cpp_0937/Solution1.h | //
// Created by ooooo on 2020/2/1.
//
#ifndef CPP_0937__SOLUTION1_H_
#define CPP_0937__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
private:
struct Word {
// 标识符
string prefix;
// 标识符后面的字符
string rest;
// 完整的字符串
string completeStr;
Word(c... |
ooooo-youwillsee/leetcode | 0200-Number-of-Islands/cpp_0200/Solution2.h | //
// Created by ooooo on 2020/2/19.
//
#ifndef CPP_0200__SOLUTION2_H_
#define CPP_0200__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* 并查集
*/
class Solution {
private:
struct UnionFind {
vector<int> parent;
vector<int> rank;
int count = 0;
UnionFind(vector<vect... |
ooooo-youwillsee/leetcode | 0594-Longest-Harmonious-Subsequence/cpp_0594/Solution2.h | //
// Created by ooooo on 2020/1/12.
//
#ifndef CPP_0594__SOLUTION2_H_
#define CPP_0594__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
/**
* 哈希表 + 单次扫描
*/
class Solution {
public:
int findLHS(vector<int> &nums) {
unordered_map<int, int> m;
int ans = 0;... |
ooooo-youwillsee/leetcode | 0914-X-of-a-Kind-in-a-Deck-of-Cards/cpp_0914/Solution1.h | /**
* @author ooooo
* @date 2020/9/30 16:20
*/
#ifndef CPP_0914__SOLUTION1_H_
#define CPP_0914__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
/**
* 求最大公约数
*/
int gcd(int x, int y) {
if (x < y) return gcd(y, x);
if (x % y == ... |
ooooo-youwillsee/leetcode | 1207-Unique-Number-of-Occurrences/cpp_1207/Solution1.h | //
// Created by ooooo on 2020/1/15.
//
#ifndef CPP_1207__SOLUTION1_H_
#define CPP_1207__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
class Solution {
public:
bool uniqueOccurrences(vector<int> &arr) {
unordered_map<int, int> m;
... |
ooooo-youwillsee/leetcode | 0839-Similar String Groups/cpp_0839/Solution1.h | <filename>0839-Similar String Groups/cpp_0839/Solution1.h
/**
* @author ooooo
* @date 2021/2/26 16:34
*/
#ifndef CPP_0839__SOLUTION1_H_
#define CPP_0839__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <set>
using namespace std;
class Solution {
public:
struct UF {
vector<int> p;
int n;
UF(... |
ooooo-youwillsee/leetcode | 0322-Coin-Change/cpp_0322/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/2/26.
//
#ifndef CPP_0322__SOLUTION2_H_
#define CPP_0322__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
/**
* dfs timeout
*/
class Solution {
public:
vector<int> coins;
unordered_map<int, int> memo;
int ans =... |
ooooo-youwillsee/leetcode | lcof_034/cpp_034/Solution1.h | //
// Created by ooooo on 2020/3/22.
//
#ifndef CPP_034__SOLUTION1_H_
#define CPP_034__SOLUTION1_H_
#include "TreeNode.h"
class Solution {
public:
void dfs(TreeNode *node, int sum, vector<int> &nums) {
if (!node) return;
sum -= node->val;
nums.push_back(node->val);
if (sum == 0 && !node->left && !... |
ooooo-youwillsee/leetcode | lcof_034/cpp_034/TreeNode.h | <filename>lcof_034/cpp_034/TreeNode.h
//
// Created by ooooo on 2020/3/22.
//
#ifndef CPP_034__TREENODE_H_
#define CPP_034__TREENODE_H_
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL),... |
ooooo-youwillsee/leetcode | 0448-Find-All-Numbers-Disappeared-in-an-Array/cpp_0448/Solution2.h | //
// Created by ooooo on 2020/2/6.
//
#ifndef CPP_0448__SOLUTION2_H_
#define CPP_0448__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
class Solution {
public:
vector<int> findDisappearedNumbers(vector<int> &nums) {
for (int i = 0; i < nums.size(); ++i) {
int ne... |
ooooo-youwillsee/leetcode | 1664-Ways to Make a Fair Array/cpp_1664/Solution1.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2020/12/11 10:31
*/
#ifndef CPP_1664__SOLUTION1_H_
#define CPP_1664__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int waysToMakeFair(vector<int> &nums) {
int n = nums.size();
if (n == 1) return 1;
vector<int... |
ooooo-youwillsee/leetcode | 0235-Lowest-Common-Ancestor-of-a-Binary-Search-Tree/cpp_0235/Solution2.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2020/9/27 11:04
*/
#ifndef CPP_0235__SOLUTION2_H_
#define CPP_0235__SOLUTION2_H_
#include "TreeNode.h"
class Solution {
public:
TreeNode *lowestCommonAncestor(TreeNode *root, TreeNode *p, TreeNode *q) {
if (root->val > p->val && root->val > q->v... |
ooooo-youwillsee/leetcode | 0530-Minimum-Absolute-Difference-in-BST/cpp_0530/Solution2.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/2.
//
#ifndef CPP_0530_SOLUTION2_H
#define CPP_0530_SOLUTION2_H
#include "TreeNode.h"
#include <climits>
/**
* 中序遍历, prev 存储前一个节点
*/
class Solution {
public:
int min;
TreeNode *prev;
void inOrder(TreeNode *node) {
if (!node) ... |
ooooo-youwillsee/leetcode | 0448-Find-All-Numbers-Disappeared-in-an-Array/cpp_0448/Solution1.h | <gh_stars>10-100
//
// Created by ooooo on 2020/2/6.
//
#ifndef CPP_0448__SOLUTION1_H_
#define CPP_0448__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
class Solution {
public:
vector<int> findDisappearedNumbers(vector<int> &nums) {
unordered_set<int> set(nums... |
ooooo-youwillsee/leetcode | 0141-Linked-List-Cycle/cpp_0141/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2019/10/30.
//
#ifndef CPP_0141_SOLUTION1_H
#define CPP_0141_SOLUTION1_H
#include <iostream>
#include "ListNode.h"
using namespace std;
class Solution1 {
public:
bool hasCycle(ListNode *head) {
if (!head) {
return false;
}
... |
ooooo-youwillsee/leetcode | 0131-Palindrome Partitioning/cpp_0131/Solution2.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2021/3/7 08:31
*/
#ifndef CPP_0131__SOLUTION2_H_
#define CPP_0131__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
void dfs(string &s, int i, vector<string> &row) {
if (i == s.size()) {
ans.p... |
ooooo-youwillsee/leetcode | 0704-Binary-Search/cpp_0704/Solution1.h | //
// Created by ooooo on 2020/1/19.
//
#ifndef CPP_0704__SOLUTION1_H_
#define CPP_0704__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int search(vector<int> &nums, int target) {
if (nums.empty()) return -1;
int left = 0, right = nums.size() - 1;
whil... |
ooooo-youwillsee/leetcode | 0226-Invert-Binary-Tree/cpp_0226/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/2.
//
#ifndef CPP_0226_SOLUTION2_H
#define CPP_0226_SOLUTION2_H
#include <queue>
#include "TreeNode.h"
class Solution {
public:
TreeNode *invertTree(TreeNode *root) {
if (!root) return nullptr;
queue<TreeNode *> q;
q.push(root);
whi... |
ooooo-youwillsee/leetcode | 0098-Validate-Binary-Search-Tree/cpp_0098/Solution3.h | //
// Created by ooooo on 2019/11/1.
//
#ifndef CPP_0098_SOLUTION3_H
#define CPP_0098_SOLUTION3_H
#include "TreeNode.h"
#include <optional>
using namespace std;
class Solution {
private:
bool help(TreeNode *node, int *min, int *max) {
if (node == NULL) {
return true;
}
if (... |
ooooo-youwillsee/leetcode | lcof_053-2/cpp_053-2/Solution3.h | //
// Created by ooooo on 2020/4/10.
//
#ifndef CPP_053_2__SOLUTION3_H_
#define CPP_053_2__SOLUTION3_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* binary
*/
class Solution {
public:
int missingNumber(vector<int> &nums) {
int l = 0, r = nums.size() - 1;
while (l <= r) {
int mi... |
ooooo-youwillsee/leetcode | 0845-Longest Mountain in Array/cpp_0845/Solution1.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
/**
* @author ooooo
* @date 2020/10/25 10:28
*/
#ifndef CPP_0845__SOLUTION1_H_
#define CPP_0845__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* dp
*/
class Solution {
public:
int longestMountain(vector<int> &A) {
if (A.size... |
ooooo-youwillsee/leetcode | 0740-Delete and Earn/cpp_0740/Solution1.h | /**
* @author ooooo
* @date 2021/5/5 09:19
*/
#ifndef CPP_0740__SOLUTION1_H_
#define CPP_0740__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int deleteAndEarn(vector<int> &nums) {
unordered_map<int, int> m;
int maxV = *max_element(nums.begin(), nums.end()... |
ooooo-youwillsee/leetcode | lcof_006/cpp_006/Solution2.h | //
// Created by ooooo on 2020/3/7.
//
#ifndef CPP_006__SOLUTION2_H_
#define CPP_006__SOLUTION2_H_
#include "ListNode.h"
/**
* O(n)
*/
class Solution {
public:
vector<int> reversePrint(ListNode *head) {
ListNode *cur = head;
vector<int> ans;
while (cur) {
ans.emplace_back(cur->val);
cur... |
ooooo-youwillsee/leetcode | 0879-Profitable Schemes/cpp_0879/Solution1.h | //
// Created by ooooo on 6/14/2021.
//
#ifndef CPP_0879_SOLUTION1_H
#define CPP_0879_SOLUTION1_H
#include <iostream>
#include <vector>
#include <cstring>
#include <numeric>
using namespace std;
class Solution {
public:
int profitableSchemes(int n, int minProfit, vector<int> &group, vector<int> &profit) {
... |
ooooo-youwillsee/leetcode | 1662-Check If Two String Arrays are Equivalent/cpp_1662/Solution1.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2020/12/11 10:25
*/
#ifndef CPP_1662__SOLUTION1_H_
#define CPP_1662__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
bool arrayStringsAreEqual(vector<string> &word1, vector<string> &word2) {
string word_seq1 = "";
... |
ooooo-youwillsee/leetcode | lcof_049/cpp_049/Solution1.h | <gh_stars>10-100
//
// Created by ooooo on 2020/4/6.
//
#ifndef CPP_049__SOLUTION1_H_
#define CPP_049__SOLUTION1_H_
#include <iostream>
#include <unordered_set>
using namespace std;
/**
* timeout
*/
class Solution {
public:
int nthUglyNumber(int n) {
unordered_set<int> s{1, 2, 3, 5};
for (int i = 1; i <... |
ooooo-youwillsee/leetcode | 0341-Flatten Nested List Iterator/cpp_0341/Solution1.h | /**
* @author ooooo
* @date 2021/3/23 15:55
*/
#ifndef CPP_0341__SOLUTION1_H_
#define CPP_0341__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class NestedInteger {
public:
// Return true if this NestedInteger holds a single integer, rather than a nested list.
bool isInteger() const;... |
ooooo-youwillsee/leetcode | 1648-Sell Diminishing-Valued Colored Balls/cpp_1648/Solution1.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2021/3/5 11:11
*/
#ifndef CPP_1648__SOLUTION1_H_
#define CPP_1648__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
class Solution {
public:
static constexpr int MOD = 1000000007;
int maxProfit(vector<int> &inventory, i... |
ooooo-youwillsee/leetcode | lcof_006/cpp_006/Solution1.h | //
// Created by ooooo on 2020/3/7.
//
#ifndef CPP_006__SOLUTION1_H_
#define CPP_006__SOLUTION1_H_
#include "ListNode.h"
/**
* O(n^2)
*/
class Solution {
public:
vector<int> reversePrint(ListNode *head) {
ListNode *cur = head;
vector<int> ans;
while (cur) {
ans.insert(ans.begin(), cur->val);
... |
ooooo-youwillsee/leetcode | 0617-Merge-Two-Binary-Trees/cpp_0617/Solution1.h | <filename>0617-Merge-Two-Binary-Trees/cpp_0617/Solution1.h<gh_stars>10-100
//
// Created by ooooo on 2019/12/31.
//
#ifndef CPP_0617_SOLUTION1_H
#define CPP_0617_SOLUTION1_H
#include "TreeNode.h"
class Solution {
public:
TreeNode *mergeTrees(TreeNode *t1, TreeNode *t2) {
if (!t1 && !t2) return nullptr;
... |
ooooo-youwillsee/leetcode | 0217-Contains-Duplicate/cpp_0217/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/6.
//
#ifndef CPP_0217_SOLUTION1_H
#define CPP_0217_SOLUTION1_H
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
class Solution {
public:
bool containsDuplicate(vector<int> &nums) {
unordered_set<int> ... |
ooooo-youwillsee/leetcode | 0328-Odd Even Linked List/cpp_0328/ListNode.h | /**
* @author ooooo
* @date 2020/11/13 21:07
*/
#ifndef CPP_0328__LISTNODE_H_
#define CPP_0328__LISTNODE_H_
#include <iostream>
#include <vector>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode() : val(0), next(nullptr) {}
ListNode(int x) : val(x), next(nullptr) {}
ListNode(int x, ... |
ooooo-youwillsee/leetcode | 0965-Univalued-Binary-Tree/cpp_0965/TreeNode.h | <filename>0965-Univalued-Binary-Tree/cpp_0965/TreeNode.h
//
// Created by ooooo on 2019/12/31.
//
#ifndef CPP_0965_TREENODE_H
#define CPP_0965_TREENODE_H
#include <iostream>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(N... |
ooooo-youwillsee/leetcode | 0896-Monotonic-Array/cpp_0896/Solution1.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
/**
* @author ooooo
* @date 2020/9/30 15:57
*/
#ifndef CPP_0896__SOLUTION1_H_
#define CPP_0896__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
bool isMonotonic(vector<int> &A) {
if (A.size() <= 2) return tr... |
ooooo-youwillsee/leetcode | 0703-Kth-Largest-Element-in-a-Stream/cpp_0703/Solution1.h | //
// Created by ooooo on 2019/10/30.
//
#ifndef CPP_0703_SOLUTION1_H
#define CPP_0703_SOLUTION1_H
#include <iostream>
#include <queue>
using namespace std;
class KthLargest {
private:
priority_queue<int, vector<int>, greater<int>> q;
int k;
public:
KthLargest(int k, vector<int> &nums) {
this-... |
ooooo-youwillsee/leetcode | 1202-Smallest String With Swaps/cpp_1202/Solution2.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2021/2/13 09:17
*/
#ifndef CPP_1202__SOLUTION2_H_
#define CPP_1202__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <stack>
#include <numeric>
#include <queue>
using namesp... |
ooooo-youwillsee/leetcode | 0287-Find-the-Duplicate-Number/cpp_0287/Solution2.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/2/23.
//
#ifndef CPP_0287__SOLUTION2_H_
#define CPP_0287__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* sort
*/
class Solution {
public:
int findDuplicate(vector<int> &nums) {
sort(nums.begin(), nums.end());
... |
ooooo-youwillsee/leetcode | lcof_032-2/cpp_032-2/Solution2.h | //
// Created by ooooo on 2020/3/20.
//
#ifndef CPP_032_2__SOLUTION2_H_
#define CPP_032_2__SOLUTION2_H_
#include "TreeNode.h"
#include <queue>
/**
* dfs
*/
class Solution {
public:
void dfs(TreeNode *node, int level) {
if (!node) return;
if (ans.size() <= level) {
ans.push_back({});
}
ans[... |
ooooo-youwillsee/leetcode | 1562-Find Latest Group of Size M/cpp_1562/Solution1.h | /**
* @author ooooo
* @date 2020/12/12 18:33
*/
#ifndef CPP_1562__SOLUTION1_H_
#define CPP_1562__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <set>
using namespace std;
class Solution {
public:
int findLatestStep(vector<int> &arr, int m) {
int n = arr.size();
if (m == n) return n;
set<int... |
ooooo-youwillsee/leetcode | 0287-Find-the-Duplicate-Number/cpp_0287/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/2/23.
//
#ifndef CPP_0287__SOLUTION1_H_
#define CPP_0287__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
/**
* hash
*/
class Solution {
public:
int findDuplicate(vector<int> &nums) {
unordere... |
ooooo-youwillsee/leetcode | lcof_048/cpp_048/Solution1.h | <gh_stars>10-100
//
// Created by ooooo on 2020/4/5.
//
#ifndef CPP_048__SOLUTION1_H_
#define CPP_048__SOLUTION1_H_
#include <iostream>
using namespace std;
/**
* 滑动窗口
*/
class Solution {
public:
int lengthOfLongestSubstring(string s) {
int i = 0, j = 0, ans = 0;
bool arr[256] = {false};
while (j < s... |
ooooo-youwillsee/leetcode | 0501-Find-Mode-in-Binary-Search-Tree/cpp_0501/TreeNode.h | <filename>0501-Find-Mode-in-Binary-Search-Tree/cpp_0501/TreeNode.h<gh_stars>10-100
//
// Created by ooooo on 2020/1/2.
//
#ifndef CPP_0501_TREENODE_H
#define CPP_0501_TREENODE_H
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
... |
ooooo-youwillsee/leetcode | 0724-Find-Pivot-Index/cpp_0724/Solution1.h | <filename>0724-Find-Pivot-Index/cpp_0724/Solution1.h
/**
* @author ooooo
* @date 2021/1/28 20:34
*/
#ifndef CPP_0724__SOLUTION1_H_
#define CPP_0724__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int pivotIndex(vector<int> &nums) {
int n = nums.size();
vec... |
ooooo-youwillsee/leetcode | 0721-Accounts Merge/cpp_0721/Solution1.h | <filename>0721-Accounts Merge/cpp_0721/Solution1.h
/**
* @author ooooo
* @date 2021/1/18 17:13
*/
#ifndef CPP_0721__SOLUTION1_H_
#define CPP_0721__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
class Solution {
public:
unordered_map<s... |
ooooo-youwillsee/leetcode | lcof_025/cpp_025/Solution2.h | //
// Created by ooooo on 2020/3/16.
//
#ifndef CPP_025__SOLUTION2_H_
#define CPP_025__SOLUTION2_H_
#include "ListNode.h"
class Solution {
public:
ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) {
if (!l1) return l2;
if (!l2) return l1;
ListNode * ans = nullptr;
if (l1->val <= l2->val) {
... |
ooooo-youwillsee/leetcode | lcof_042/cpp_042/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/3/27.
//
#ifndef CPP_042__SOLUTION1_H_
#define CPP_042__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int maxSubArray(vector<int> &nums) {
int n = nums.size(), ans = nums[0];
vector<int> d... |
ooooo-youwillsee/leetcode | 0959-Regions Cut By Slashes/cpp_0959/Solution1.h | /**
* @author ooooo
* @date 2021/1/25 19:35
*/
#ifndef CPP_0959__SOLUTION1_H_
#define CPP_0959__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
class Solution {
public:
struct UF {
int n;
vector<int> p;
UF(int n) : n(n), p(n) {
for (int i = 0; i < n; ++i) {
... |
ooooo-youwillsee/leetcode | 0337-House-Robber-III/cpp_0337/Solution1.h | //
// Created by ooooo on 2020/2/25.
//
#ifndef CPP_0337__SOLUTION1_H_
#define CPP_0337__SOLUTION1_H_
#include "TreeNode.h"
using namespace std;
class Solution {
public:
int dfs(TreeNode *node, bool rob) {
if (!node) return 0;
// 添加下面这一行,减少递归次数,程序通过!!!
if (!node->left && !node->right) return rob ? no... |
ooooo-youwillsee/leetcode | 0096-Unique-Binary-Search-Trees/cpp_0096/Solution1.h | //
// Created by ooooo on 2020/2/15.
//
#ifndef CPP_0096__SOLUTION1_H_
#define CPP_0096__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* f(i,n) 表示以 i 为根,长度为 n 的个数 ( 1 <= i <= n)
* G(n) 表示长度为 n 的总个数
* 即: G(n) = f(1, n) + f(2, n) +...+ f(n, n)
* 而 f(i, n) = G(i-1) * G(n-i)
*
* ==> ... |
ooooo-youwillsee/leetcode | 0020-Valid-Parentheses/cpp_0020/Solution1.h | //
// Created by ooooo on 2019/10/30.
//
#ifndef CPP_0020_SOLUTION1_H
#define CPP_0020_SOLUTION1_H
#include <iostream>
#include <stack>
#include <map>
using namespace std;
class Solution1 {
public:
bool isValid(string s) {
stack<char> stack;
map<char, char> map;
map['}'] = '{';
ma... |
ooooo-youwillsee/leetcode | 0500-Keyboard-Row/cpp_0500/Solution1.h | <reponame>ooooo-youwillsee/leetcode<filename>0500-Keyboard-Row/cpp_0500/Solution1.h
//
// Created by ooooo on 2020/1/11.
//
#ifndef CPP_0500__SOLUTION1_H_
#define CPP_0500__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
vector<string> fin... |
ooooo-youwillsee/leetcode | 0205-Isomorphic-Strings/cpp_0205/Solution1.h | //
// Created by ooooo on 2020/1/9.
//
#ifndef CPP_0205_SOLUTION1_H
#define CPP_0205_SOLUTION1_H
#include <iostream>
#include <unordered_map>
using namespace std;
class Solution {
public:
bool isIsomorphic(string s, string t) {
unordered_map<char, char> m1;
unordered_map<char, char> m2;
f... |
ooooo-youwillsee/leetcode | 0834-Sum of Distances in Tree/cpp_0834/Solution1.h | /**
* @author ooooo
* @date 2020/10/6 11:59
*/
#ifndef CPP_0834__SOLUTION1_H_
#define CPP_0834__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;
/**
* bfs timeout
*/
class Solution {
public:
int bfs(vector<vector<int>> &g, int i) {
vector<int> d(... |
ooooo-youwillsee/leetcode | 1785-Minimum Elements to Add to Form a Given Sum/cpp_1785/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2021/3/14 15:01
*/
#ifndef CPP_1785__SOLUTION1_H_
#define CPP_1785__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <stack>
#include <numeric>
#include <queue>
using namesp... |
ooooo-youwillsee/leetcode | lcof_012/cpp_012/Solution1.h | //
// Created by ooooo on 2020/3/10.
//
#ifndef CPP_012__SOLUTION1_H_
#define CPP_012__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* dfs( rows * cols * len(word))
*/
class Solution {
public:
bool is_valid(int i, int j, int word_index) {
return i >= 0 && i < board.size() && j... |
ooooo-youwillsee/leetcode | 1824-Minimum Sideway Jumps/cpp_1824/Solution1.h | /**
* @author ooooo
* @date 2021/4/19 09:37
*/
#ifndef CPP_1824__SOLUTION1_H_
#define CPP_1824__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution1 {
public:
int minSideJumps(vector<int> nums) {
int n = nums.size();
vector<vector<int>> dp(n, vector<int>(4, n * 3 + 1));
... |
ooooo-youwillsee/leetcode | 0389-Find-the-Difference/cpp_0389/Solution2.h | //
// Created by ooooo on 2020/1/11.
//
#ifndef CPP_0389__SOLUTION2_H_
#define CPP_0389__SOLUTION2_H_
#include <iostream>
#include <unordered_map>
using namespace std;
/**
* map
*/
class Solution {
public:
char findTheDifference(string s, string t) {
unordered_map<char, int> m;
for (auto &c:s) {
m... |
ooooo-youwillsee/leetcode | 0347-Top-K-Frequent-Elements/cpp_0347/Solution1.h | //
// Created by ooooo on 2020/1/24.
//
#ifndef CPP_0347__SOLUTION1_H_
#define CPP_0347__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
using namespace std;
class Solution {
public:
struct Freq {
int val;
int times;
Freq(int val, int times) : val(val), ti... |
ooooo-youwillsee/leetcode | lcp-18/cpp_018/Solution1.h | /**
* @author ooooo
* @date 2020/9/26 17:23
*/
#ifndef CPP_018__SOLUTION1_H_
#define CPP_018__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int breakfastNumber(vector<int> &staple, vector<int> &drinks, int x) {
sort(staple.begin(), staple.end());
sort(dri... |
ooooo-youwillsee/leetcode | lcof_045/cpp_045/Solution2.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/4/1.
//
#ifndef CPP_045__SOLUTION2_H_
#define CPP_045__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
/**
* ab < ba
*/
class Solution {
public:
string minNumber(vector<int> &nums) {
vector<string>... |
ooooo-youwillsee/leetcode | 0106-Construct-Binary-Tree-from-Inorder-and-Postorder-Traversal/cpp_0106/Solution1.h | <filename>0106-Construct-Binary-Tree-from-Inorder-and-Postorder-Traversal/cpp_0106/Solution1.h
/**
* @author ooooo
* @date 2020/9/25 09:24
*/
#ifndef CPP_0106__SOLUTION1_H_
#define CPP_0106__SOLUTION1_H_
#include "TreeNode.h"
class Solution {
public:
vector<int> postorder;
int k; // 后序位置,用于判断根节点
TreeNode *... |
ooooo-youwillsee/leetcode | 1035-Uncrossed Lines/cpp_1035/Solution1.h | /**
* @author ooooo
* @date 2021/5/21 07:35
*/
#ifndef CPP_1035__SOLUTION1_H_
#define CPP_1035__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int maxUncrossedLines(vector<int> &nums1, vector<int> &nums2) {
int m = nums1.size(), n = nums2.size();
vector<ve... |
ooooo-youwillsee/leetcode | 0763-Partition Labels/cpp_0763/Solution2.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
/**
* @author ooooo
* @date 2020/10/22 15:49
*/
#ifndef CPP_0763__SOLUTION2_H_
#define CPP_0763__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
vector<int> partitionLabels(string s) ... |
ooooo-youwillsee/leetcode | 0993-Cousins-in-Binary-Tree/cpp_0993/Solution3.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2021/5/17 21:58
*/
#ifndef CPP_0993__SOLUTION3_H_
#define CPP_0993__SOLUTION3_H_
#include "TreeNode.h"
#include <iostream>
#include <queue>
using namespace std;
class Solution {
public:
bool isCousins(TreeNode *root, int x, int y) {
if (!root) return false;
qu... |
ooooo-youwillsee/leetcode | lcp-19/cpp_019/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2020/10/1 18:31
*/
#ifndef CPP_019__SOLUTION1_H_
#define CPP_019__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
// 状态0 表示 最左边的为红色
// 状态1 表示 中间的为黄色
// 状态2 表示 最右边的为红色
int minimumOperations(stri... |
ooooo-youwillsee/leetcode | 0023-Merge-k-Sorted-Lists/cpp_0023/ListNode.h | /**
* @author ooooo
* @date 2020/9/25 22:36
*/
#ifndef CPP_0023__LISTNODE_H_
#define CPP_0023__LISTNODE_H_
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode() : val(0), next(nullptr) {}
ListNode(int x) : val(x), next(nullptr) {}
... |
ooooo-youwillsee/leetcode | 1442-Count Triplets That Can Form Two Arrays of Equal XOR/cpp_1442/Solution1.h | <filename>1442-Count Triplets That Can Form Two Arrays of Equal XOR/cpp_1442/Solution1.h
/**
* @author ooooo
* @date 2021/5/22 11:37
*/
#ifndef CPP_1442__SOLUTION1_H_
#define CPP_1442__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int countTriplets(vector<int... |
ooooo-youwillsee/leetcode | 0222-Count Complete Tree Nodes/cpp_0222/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2020/11/24 09:07
*/
#ifndef CPP_0222__SOLUTION1_H_
#define CPP_0222__SOLUTION1_H_
#include "TreeNode.h"
class Solution {
public:
int countNodes(TreeNode *root) {
if (root == nullptr) return 0;
return countNodes(root->left) + countNodes(root->r... |
ooooo-youwillsee/leetcode | 0387-First-Unique-Character-in-a-String/cpp_0387/Solution1.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/11.
//
#ifndef CPP_0387__SOLUTION1_H_
#define CPP_0387__SOLUTION1_H_
#include <iostream>
#include <unordered_map>
using namespace std;
class Solution {
public:
int firstUniqChar(string s) {
unordered_map<char, int> m;
for (auto &c: s) {
m[c]++;
}... |
ooooo-youwillsee/leetcode | 1680-Concatenation of Consecutive Binary Numbers/cpp_1680/Solution1.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2021/2/14 09:55
*/
#ifndef CPP_1680__SOLUTION1_H_
#define CPP_1680__SOLUTION1_H_
#include <iostream>
using namespace std;
class Solution {
public:
static const long MOD = 1000000007;
int concatenatedBinary(int n) {
long ans = 0;
for (int i = 1; i <= n; ++i) ... |
ooooo-youwillsee/leetcode | 0509-Fibonacci-Number/cpp_0509/Solution2.h | //
// Created by ooooo on 2020/1/6.
//
#ifndef CPP_0509_SOLUTION2_H
#define CPP_0509_SOLUTION2_H
#include <iostream>
#include <vector>
using namespace std;
/**
* loop
*/
class Solution {
public:
int fib2(int N) {
if (N == 0 || N == 1) return N;
vector<int> ans = {0, 1};
for (int i = 2; ... |
ooooo-youwillsee/leetcode | 0705-Design HashSet/cpp_0705/Solution1.h | <filename>0705-Design HashSet/cpp_0705/Solution1.h
//
// Created by ooooo on 2020/1/13.
//
#ifndef CPP_0705__SOLUTION1_H_
#define CPP_0705__SOLUTION1_H_
#include <iostream>
using namespace std;
class MyHashSet {
private:
struct Node {
int val;
Node *next;
Node(int val) : val(val), next(nullptr) {}
... |
ooooo-youwillsee/leetcode | lcof_021/cpp_021/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/3/15.
//
#ifndef CPP_021__SOLUTION1_H_
#define CPP_021__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* 双指针
*/
class Solution {
public:
vector<int> exchange(vector<int> &nums) {
int l = 0, r = nums.size() - 1;
... |
ooooo-youwillsee/leetcode | 0094-Binary-Tree-Inorder-Traversal/cpp_0094/TreeNode.h | <gh_stars>10-100
//
// Created by ooooo on 2020/2/15.
//
#ifndef CPP_0094__TREENODE_H_
#define CPP_0094__TREENODE_H_
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
... |
ooooo-youwillsee/leetcode | 0113-Path-Sum-II/cpp_0113/Solution1.h | <filename>0113-Path-Sum-II/cpp_0113/Solution1.h
/**
* @author ooooo
* @date 2020/9/26 00:13
*/
#ifndef CPP_0113__SOLUTION1_H_
#define CPP_0113__SOLUTION1_H_
#include "TreeNode.h"
class Solution {
public:
void dfs(TreeNode *node, int sum, vector<int> &temp) {
if (!node) return;
temp.emplace_back(node->val)... |
ooooo-youwillsee/leetcode | 0234-Palindrome-Linked-List/cpp_0234/Solution3.h | <filename>0234-Palindrome-Linked-List/cpp_0234/Solution3.h
//
// Created by ooooo on 2020/1/8.
//
#ifndef CPP_0234_SOLUTION3_H
#define CPP_0234_SOLUTION3_H
#include "ListNode.h"
class Solution {
public:
bool isPalindrome(ListNode *head) {
if (!head || !head->next) return true;
ListNode *low = he... |
ooooo-youwillsee/leetcode | 1704-Determine if String Halves Are Alike/cpp_1704/Solution1.h | <filename>1704-Determine if String Halves Are Alike/cpp_1704/Solution1.h
/**
* @author ooooo
* @date 2021/1/24 17:14
*/
#ifndef CPP_1704__SOLUTION1_H_
#define CPP_1704__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <... |
ooooo-youwillsee/leetcode | 0692-Top K Frequent Words/cpp_0692/Solution1.h | /**
* @author ooooo
* @date 2021/5/20 07:31
*/
#ifndef CPP_0692__SOLUTION1_H_
#define CPP_0692__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
using namespace std;
class Solution {
public:
vector<string> topKFrequent(vector<string> &words, int k) {
unordered_map... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.