repo_name stringlengths 5 122 | path stringlengths 3 232 | text stringlengths 6 1.05M |
|---|---|---|
ooooo-youwillsee/leetcode | lcof_067/cpp_067/Solution1.h | //
// Created by ooooo on 2020/4/27.
//
#ifndef CPP_067__SOLUTION1_H_
#define CPP_067__SOLUTION1_H_
#include <iostream>
using namespace std;
class Solution {
public:
int strToInt(string str) {
int i = 0;
for (; i < str.size() && str[i] == ' '; i++) {}
bool flag = true;
if (str[i] == '-' || str[i]... |
ooooo-youwillsee/leetcode | lcof_051/cpp_051/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/4/8.
//
#ifndef CPP_051__SOLUTION1_H_
#define CPP_051__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int __merge(int l, int mid, int r, vector<int> &tmp) {
int i = mid, j = r, count = 0, k = ... |
ooooo-youwillsee/leetcode | 0374-Guess-Number-Higher-or-Lower/cpp_0374/Solution1.h | //
// Created by ooooo on 2020/1/18.
//
#ifndef CPP_0374__SOLUTION1_H_
#define CPP_0374__SOLUTION1_H_
#include <iostream>
using namespace std;
// Forward declaration of guess API.
// @param num, your guess
// @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
int guess(int num) {
return... |
ooooo-youwillsee/leetcode | 0015-3Sum/cpp_0015/Solution1.h | //
// Created by ooooo on 2019/10/31.
//
#ifndef CPP_0015_SOLUTION1_H
#define CPP_0015_SOLUTION1_H
#include <vector>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
class Solution {
public:
vector<vector<int>> threeSum(vector<int> &nums) {
vector<vector<int>> result;
... |
ooooo-youwillsee/leetcode | 0048-Rotate-Image/cpp_0048/Solution2.h | //
// Created by ooooo on 2020/2/11.
//
#ifndef CPP_0048__SOLUTION2_H_
#define CPP_0048__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
void rotate(vector<vector<int>> &matrix) {
int n = matrix.size();
for (int i = 0; i <= n / 2; i++)
for (int j = i... |
ooooo-youwillsee/leetcode | 0448-Find-All-Numbers-Disappeared-in-an-Array/cpp_0448/Solution3.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/2/6.
//
#ifndef CPP_0448__SOLUTION3_H_
#define CPP_0448__SOLUTION3_H_
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
/**
* 从第一个数字开始,逐一置为-1
*/
class Solution {
public:
vector<int> findDisappearedNumbers(vector<int> &n... |
ooooo-youwillsee/leetcode | 0002-Add-Two-Numbers/cpp_0002/Solution1.h | /**
* @author ooooo
* @date 2020/10/4 12:43
*/
#ifndef CPP_0002__SOLUTION1_H_
#define CPP_0002__SOLUTION1_H_
#include "ListNode.h"
class Solution {
public:
ListNode *addTwoNumbers2(ListNode *l1, ListNode *l2) {
ListNode *dummyHead = new ListNode(-1), *cur = dummyHead;
int carry = 0;
while (l1 || l2) {
... |
ooooo-youwillsee/leetcode | 0977-Squares-of-a-Sorted-Arrays/cpp_0977/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/7.
//
#ifndef CPP_0977_SOLUTION2_H
#define CPP_0977_SOLUTION2_H
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
/**
* 双指针
*/
class Solution {
public:
vector<int> sortedSquares(vector<int> &A) {
if (A.empty()) return A;
... |
ooooo-youwillsee/leetcode | 0965-Univalued-Binary-Tree/cpp_0965/Solution2.h | //
// Created by ooooo on 2019/12/31.
//
#ifndef CPP_0965_SOLUTION2_H
#define CPP_0965_SOLUTION2_H
#include "TreeNode.h"
#include <queue>
class Solution {
public:
bool isUnivalTree(TreeNode *root) {
if (!root) return true;
int x = root->val;
queue<TreeNode *> q;
q.push(root);
... |
ooooo-youwillsee/leetcode | 1074-Number of Submatrices That Sum to Target/cpp_1074/Solution2.h | <filename>1074-Number of Submatrices That Sum to Target/cpp_1074/Solution2.h
//
// Created by ooooo on 5/31/2021.
//
#ifndef CPP_1074_SOLUTION2_H
#define CPP_1074_SOLUTION2_H
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
int numSubmatrixSumTarget(v... |
ooooo-youwillsee/leetcode | 1449-Form Largest Integer With Digits That Add up to Target/cpp_1449/Solution1.h | //
// Created by ooooo on 6/15/2021.
//
#ifndef CPP_1449_SOLUTION1_H
#define CPP_1449_SOLUTION1_H
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
string largestNumber(vector<int> &cost, int target) {
int n = cost.size();
// 恰好为target,所以初始化为 INT_MIN
vector<in... |
ooooo-youwillsee/leetcode | 1438-Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/cpp_1438/Solution2.h | /**
* @author ooooo
* @date 2021/2/21 09:14
*/
#ifndef CPP_1438__SOLUTION2_H_
#define CPP_1438__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <set>
#include <queue>
using namespace std;
// 单调队列维护区间的最值
class Solution {
public:
int longestSubarray(vector<int> &nums, int limit) {
int l = 0, r = 0... |
ooooo-youwillsee/leetcode | 0204-Count-Primes/cpp_0204/Solution1.h | //
// Created by ooooo on 2020/1/8.
//
#ifndef CPP_0204_SOLUTION1_H
#define CPP_0204_SOLUTION1_H
#include <iostream>
#include <cmath>
using namespace std;
class Solution {
public:
bool isPrime(int num) {
if (num == 2) return true;
if ((num & 1) == 0 || num == 1) {
return false;
... |
ooooo-youwillsee/leetcode | 1790-Check if One String Swap Can Make Strings Equal/cpp_1790/Solution1.h | <filename>1790-Check if One String Swap Can Make Strings Equal/cpp_1790/Solution1.h<gh_stars>10-100
/**
* @author ooooo
* @date 2021/3/28 12:10
*/
#ifndef CPP_1790__SOLUTION1_H_
#define CPP_1790__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#i... |
ooooo-youwillsee/leetcode | 0079-Word-Search/cpp_0079/Solution1.h | <reponame>ooooo-youwillsee/leetcode<filename>0079-Word-Search/cpp_0079/Solution1.h
//
// Created by ooooo on 2019/12/4.
//
#ifndef CPP_0079_SOLUTION1_H
#define CPP_0079_SOLUTION1_H
#include <vector>
#include <iostream>
using namespace std;
class Solution {
private:
vector<vector<bool>> marked;
int m; // 行
... |
ooooo-youwillsee/leetcode | 0859-Buddy-Strings/cpp_0859/Solution2.h | //
// Created by ooooo on 2020/1/31.
//
#ifndef CPP_0859__SOLUTION2_H_
#define CPP_0859__SOLUTION2_H_
#include <iostream>
#include <unordered_set>
using namespace std;
class Solution {
public:
bool buddyStrings(string A, string B) {
if (A.size() != B.size() || A.empty() || B.empty()) return false;
if (A ... |
ooooo-youwillsee/leetcode | lcof_035/cpp_035/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/3/22.
//
#ifndef CPP_035__SOLUTION1_H_
#define CPP_035__SOLUTION1_H_
#include "Node.h"
#include <unordered_map>
class Solution {
public:
Node *copyRandomList(Node *head) {
if (!head) return nullptr;
unordered_map<Node *, Node *> node_map;
... |
ooooo-youwillsee/leetcode | 0973-K Closest Points to Origin/cpp_0973/Solution2.h | /**
* @author ooooo
* @date 2020/11/9 09:12
*/
#ifndef CPP_0973__SOLUTION2_H_
#define CPP_0973__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
/*
* sort
*/
class Solution {
public:
vector<vector<int>> kClosest(vector<vector<int>> &points, int K) {
sort(points.beg... |
ooooo-youwillsee/leetcode | 0055-Jump-Game/cpp_0055/Solution3.h | <gh_stars>10-100
//
// Created by ooooo on 2020/2/12.
//
#ifndef CPP_0055__SOLUTION3_H_
#define CPP_0055__SOLUTION3_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* 贪心
*/
class Solution {
public:
bool canJump(vector<int> &nums) {
// k 表示能跳的最远距离
int k = 0;
for (int i = 0; i < nums.... |
ooooo-youwillsee/leetcode | 0013-Roman-to-Integer/cpp_0013/Solution1.h | //
// Created by ooooo on 2020/1/24.
//
#ifndef CPP_0013__SOLUTION1_H_
#define CPP_0013__SOLUTION1_H_
#include <iostream>
#include <unordered_map>
using namespace std;
class Solution {
public:
unordered_map<char, int> m = {
{'I', 1}, {'V', 5}, {'X', 10}, {'L', 50},
{'C', 100}, {'D', 500}, {'M', 1000}
... |
ooooo-youwillsee/leetcode | lcof_060/cpp_060/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/4/20.
//
#ifndef CPP_060__SOLUTION1_H_
#define CPP_060__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
class Solution {
public:
vector<double> twoSum(int n) {
int max_count = 6; // 最大的点数
vector<vec... |
ooooo-youwillsee/leetcode | 0350-Intersection-of-Two-Arrays-II/cpp_0350/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2019/12/29.
//
#ifndef CPP_0350_SOLUTION1_H
#define CPP_0350_SOLUTION1_H
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
vector<int> intersect(vector<int> &nums1, vector<int> &nums2) {
... |
ooooo-youwillsee/leetcode | 0164-Maximum Gap/cpp_0164/Solution1.h | /**
* @author ooooo
* @date 2020/11/26 16:28
*/
#ifndef CPP_0164__SOLUTION1_H_
#define CPP_0164__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int maximumGap(vector<int> &nums) {
if (nums.size() < 2) return 0;
sort(nums.begin(), nums.end());
int diff = ... |
ooooo-youwillsee/leetcode | 0441-Arranging-Coins/cpp_0441/Solution2.h | //
// Created by ooooo on 2020/1/19.
//
#ifndef CPP_0441__SOLUTION2_H_
#define CPP_0441__SOLUTION2_H_
#include <iostream>
using namespace std;
/**
* binary search
*/
class Solution {
public:
int arrangeCoins(int n) {
if (n <= 1) return n;
long left = 1, right = n, mid = 0, sum = 0;
while (left <= ri... |
ooooo-youwillsee/leetcode | 0330-Patching Array/cpp_0330/Solution1.h | /**
* @author ooooo
* @date 2020/12/29 17:36
*/
#ifndef CPP_0330__SOLUTION1_H_
#define CPP_0330__SOLUTION1_H_
#include <vector>
#include <iostream>
using namespace std;
class Solution {
public:
int minPatches(vector<int> &nums, int n) {
int patches = 0;
long long x = 1;
int length = nums.size(), index =... |
ooooo-youwillsee/leetcode | 0938-Range-Sum-of-BST/cpp_0938/TreeNode.h | //
// Created by ooooo on 2019/12/31.
//
#ifndef CPP_0938_TREENODE_H
#define CPP_0938_TREENODE_H
#include <iostream>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
/**
* @return left <= x <= right
*/
bool ma... |
ooooo-youwillsee/leetcode | lcof_018/cpp_018/Solution1.h | //
// Created by ooooo on 2020/3/13.
//
#ifndef CPP_018__SOLUTION1_H_
#define CPP_018__SOLUTION1_H_
#include "ListNode.h"
class Solution {
public:
ListNode *deleteNode(ListNode *head, int val) {
ListNode *dummyHead = new ListNode(0), *prev = dummyHead;
dummyHead->next = head;
while (prev->next) {
... |
ooooo-youwillsee/leetcode | 0164-Maximum Gap/cpp_0164/Solution2.h | <reponame>ooooo-youwillsee/leetcode<filename>0164-Maximum Gap/cpp_0164/Solution2.h
/**
* @author ooooo
* @date 2020/11/26 19:19
*/
#ifndef CPP_0164__SOLUTION2_H_
#define CPP_0164__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int maximumGap(vector<int> &nums)... |
ooooo-youwillsee/leetcode | 0494-Target-Sum/cpp_0494/Solution2.h | //
// Created by ooooo on 2020/3/3.
//
#ifndef CPP_0494__SOLUTION2_H_
#define CPP_0494__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
/**
* dp[i][j] = dp[i-1][j-nums[i]] + dp[i-1][j+nums[i]]
*
* 背包问题
*
*/
class Solution {
public:
int findTargetSumWays(vector<int>& ... |
ooooo-youwillsee/leetcode | 0237-Delete-Node-in-a-Linked-List/cpp_0237/Solution1.h | //
// Created by ooooo on 2020/1/23.
//
#ifndef CPP_0237__SOLUTION1_H_
#define CPP_0237__SOLUTION1_H_
#include "ListNode.h"
class Solution {
public:
void deleteNode(ListNode *node) {
ListNode *cur = node;
while (cur && cur->next) {
cur->val = cur->next->val;
if (!cur->next->next) {
cur-... |
ooooo-youwillsee/leetcode | 0021-Merge-Two-Sorted-Lists/cpp_0021/Solution3.h | //
// Created by ooooo on 2020/1/23.
//
#ifndef CPP_0021__SOLUTION3_H_
#define CPP_0021__SOLUTION3_H_
#include "ListNode.h"
/**
* recursion
*/
class Solution {
public:
ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) {
if (!l1) return l2;
if (!l2) return l1;
if (l1->val < l2->val) {
l1->nex... |
ooooo-youwillsee/leetcode | 0819-Most-Common-Word/cpp_0819/Solution1.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/30.
//
#ifndef CPP_0819__SOLUTION1_H_
#define CPP_0819__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <regex>
#include <unordered_map>
#include <unordered_set>
using namespace std;
/**
* timeout ???
*/
class Solution {
public:
string mostCommonWord... |
ooooo-youwillsee/leetcode | 0304-Range Sum Query 2D - Immutable/cpp_0304/Solution2.h | <filename>0304-Range Sum Query 2D - Immutable/cpp_0304/Solution2.h
/**
* @author ooooo
* @date 2021/3/2 16:41
*/
#ifndef CPP_0304__SOLUTION2_H_
#define CPP_0304__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
class NumMatrix {
public:
vector<vector<int>> preSum;
NumMatrix(vector<vec... |
ooooo-youwillsee/leetcode | 1438-Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/cpp_1438/Solution1.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
/**
* @author ooooo
* @date 2021/2/21 08:46
*/
#ifndef CPP_1438__SOLUTION1_H_
#define CPP_1438__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <set>
using namespace std;
class Solution {
public:
int longestSubarray(vector<int> &nums, int limit) ... |
ooooo-youwillsee/leetcode | 0198-House-Robber/cpp_0198/Solution1.h | //
// Created by ooooo on 2020/2/5.
//
#ifndef CPP_0198__SOLUTION1_H_
#define CPP_0198__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* dp[i][1] = dp[i-1][0] + p
* dp[i][0] = max(dp[i-1][0], dp[i-1][1] )
*/
class Solution {
public:
int rob(vector<int> &nums) {
int ans = 0, n =... |
ooooo-youwillsee/leetcode | 1640-Check Array Formation Through Concatenation/cpp_1640/Solution1.h | /**
* @author ooooo
* @date 2020/11/15 09:33
*/
#ifndef CPP_1640__SOLUTION1_H_
#define CPP_1640__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
class Solu... |
ooooo-youwillsee/leetcode | 0321-Create Maximum Number/cpp_0321/Solution1.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2020/12/3 12:27
*/
#ifndef CPP_0321__SOLUTION1_H_
#define CPP_0321__SOLUTION1_H_
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
class Solution {
public:
// 自定义比较函数, 处理情况 num1:[6,7] num2:[6,0,4] k=5
bool compare(vector<int> &nums1, in... |
ooooo-youwillsee/leetcode | 0047-Permutations-II/cpp_0047/Solution1.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2020/9/18 09:18
*/
#ifndef CPP_0047__SOLUTION1_H_
#define CPP_0047__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
void permuteUnique(vector<int> nums, int i) {
if (i == nums.size() - 1) {
ans.push_back(nums);... |
ooooo-youwillsee/leetcode | 0338-Counting Bits/cpp_0338/Solution1.h | //
// Created by ooooo on 2019/12/5.
//
#ifndef CPP_0338_SOLUTION1_H
#define CPP_0338_SOLUTION1_H
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
vector<int> countBits(int num) {
vector<int> res = vector<int>(num + 1, 0);
for (int i = 1; i <= num; i++) {
... |
ooooo-youwillsee/leetcode | 1689-Partitioning Into Minimum Number Of Deci-Binary Numbers/cpp_1689/Solution1.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
/**
* @author ooooo
* @date 2020/12/20 12:59
*/
#ifndef CPP_1689__SOLUTION1_H_
#define CPP_1689__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int minPartitions(string n) {
int ans = 0;
for (int i = 0; i... |
ooooo-youwillsee/leetcode | 0067-Add-Binary/cpp_0067/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/25.
//
#ifndef CPP_0067__SOLUTION1_H_
#define CPP_0067__SOLUTION1_H_
#include <iostream>
using namespace std;
/**
* 从尾遍历到头
*/
class Solution {
public:
string addBinary(string a, string b) {
string ans = "";
int i = a.size() - 1, j = b... |
ooooo-youwillsee/leetcode | 0036-Valid-Sudoku/cpp_0036/Solution1.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
//
// Created by ooooo on 2019/11/21.
//
#ifndef CPP_0036_SOLUTION1_H
#define CPP_0036_SOLUTION1_H
#include <iostream>
#include <vector>
using namespace std;
class Solution1 {
private:
public:
bool isValidSudoku(vector<vector<char>> &board) {
int row[... |
ooooo-youwillsee/leetcode | 1609-Even Odd Tree/cpp_1609/TreeNode.h | /**
* @author ooooo
* @date 2020/10/11 13:42
*/
#ifndef CPP_1609__TREENODE_H_
#define CPP_1609__TREENODE_H_
#include <iostream>
#include <vector>
#include <unordered_set>
#include <queue>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode() : val(0), left(nullptr), rig... |
ooooo-youwillsee/leetcode | 0019-Remove-Nth-Node-From-End-of-List/cpp_0019/Solution1.h | <gh_stars>10-100
//
// Created by ooooo on 2020/2/8.
//
#ifndef CPP_0019__SOLUTION1_H_
#define CPP_0019__SOLUTION1_H_
#include "ListNode.h"
#include <vector>
class Solution {
public:
ListNode *removeNthFromEnd(ListNode *head, int n) {
vector<ListNode *> nodes;
ListNode *dummyNode = new ListNode(0), *cur = ... |
ooooo-youwillsee/leetcode | 0011-Container-With-Most-Water/cpp_0011/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/2/6.
//
#ifndef CPP_0011__SOLUTION2_H_
#define CPP_0011__SOLUTION2_H_
#include <iostream>
#include <vector>
/**
* 双指针
*/
using namespace std;
class Solution {
public:
int maxArea(vector<int> &height) {
int ans = 0, left = 0, right = height.size() - 1;
whil... |
ooooo-youwillsee/leetcode | 0328-Odd Even Linked List/cpp_0328/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2020/11/13 21:07
*/
#ifndef CPP_0328__SOLUTION1_H_
#define CPP_0328__SOLUTION1_H_
#include "ListNode.h"
class Solution {
public:
ListNode *oddEvenList(ListNode *head) {
if (!head || !head->next) return head;
ListNode *odd = head, *even = head-... |
ooooo-youwillsee/leetcode | lcof_053-1/cpp_053-1/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/4/9.
//
#ifndef CPP_053_1__SOLUTION1_H_
#define CPP_053_1__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int search(vector<int> &nums, int target) {
int count = 0;
for (auto &num: nums) {
... |
ooooo-youwillsee/leetcode | 1864-Minimum Number of Swaps to Make the Binary String Alternating/cpp_1864/Solution1.h | <filename>1864-Minimum Number of Swaps to Make the Binary String Alternating/cpp_1864/Solution1.h
/**
* @author ooooo
* @date 2021/5/25 22:16
*/
#ifndef CPP_1864__SOLUTION1_H_
#define CPP_1864__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int cntSwap(string... |
ooooo-youwillsee/leetcode | 0690-Employee-Importance/cpp_0690/Solution1.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
//
// Created by ooooo on 2020/1/13.
//
#ifndef CPP_0690__SOLUTION1_H_
#define CPP_0690__SOLUTION1_H_
#include "Employee.h"
#include <unordered_map>
/**
* loop
*/
class Solution {
public:
int getImportance(vector<Employee *> employees, int id) {
unordered_m... |
ooooo-youwillsee/leetcode | 0205-Isomorphic-Strings/cpp_0205/Solution2.h | //
// Created by ooooo on 2020/1/9.
//
#ifndef CPP_0205_SOLUTION2_H
#define CPP_0205_SOLUTION2_H
#include <iostream>
#include <unordered_map>
using namespace std;
class Solution {
public:
bool help(string s, string t) {
unordered_map<char, char> m;
for (int i = 0; i < s.size(); ++i) {
... |
ooooo-youwillsee/leetcode | 0154-Find Minimum in Rotated Sorted Array II/cpp_0154/Solution1.h | /**
* @author ooooo
* @date 2021/4/9 13:08
*/
#ifndef CPP_0154__SOLUTION1_H_
#define CPP_0154__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int findMin(vector<int> &nums) {
int n = nums.size();
int l = 0, r = n - 1;
if (nums[l] < nums[r]) return nums[l... |
ooooo-youwillsee/leetcode | 0279-Perfect-Squares/cpp_0279/Solution4.h | //
// Created by ooooo on 2020/2/23.
//
#ifndef CPP_0279__SOLUTION4_H_
#define CPP_0279__SOLUTION4_H_
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
using namespace std;
/**
* bfs 这一题相当于 查找最短路径(n -> 0)
*/
class Solution {
public:
int numSquares(int n) {
unordered_set<int> s... |
ooooo-youwillsee/leetcode | lcof_011/cpp_011/Solution1.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
//
// Created by ooooo on 2020/3/9.
//
#ifndef CPP_011__SOLUTION1_H_
#define CPP_011__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* O(n)
*/
class Solution {
public:
int minArray(vector<int> &numbers) {
for (int i = 0, len = ... |
ooooo-youwillsee/leetcode | 0331-Verify Preorder Serialization of a Binary Tree/cpp_0331/Solution1.h | /**
* @author ooooo
* @date 2021/3/12 10:17
*/
#ifndef CPP_0331__SOLUTION1_H_
#define CPP_0331__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
struct Node {
Node *left, *right;
int value;
Node(int value) : value(value) {
this->left = this->right = n... |
ooooo-youwillsee/leetcode | 0590-N-ary-Tree-Postorder-Transversal/cpp_0590/Solution2.h | //
// Created by ooooo on 2020/1/3.
//
#ifndef CPP_0590_SOLUTION2_H
#define CPP_0590_SOLUTION2_H
#include "Node.h"
#include <stack>
class Solution {
public:
vector<int> postorder(Node *root) {
if(!root) return {};
stack<Node *> s;
s.push(root);
vector<int> res;
while (!s.em... |
ooooo-youwillsee/leetcode | 1202-Smallest String With Swaps/cpp_1202/Solution1.h | /**
* @author ooooo
* @date 2021/1/11 09:14
*/
#ifndef CPP_1202__SOLUTION1_H_
#define CPP_1202__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
using namespace std;
// sort
class Solution {
public:
string smallestStringWithSwaps(string s, vector<vector<int>> &pairs... |
ooooo-youwillsee/leetcode | lcof_052/cpp_052/Solution1.h | //
// Created by ooooo on 2020/4/9.
//
#ifndef CPP_052__SOLUTION1_H_
#define CPP_052__SOLUTION1_H_
#include "ListNode.h"
#include <unordered_set>
class Solution {
public:
ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
unordered_set<ListNode *> nodes;
for (; headA; headA = headA->next) no... |
ooooo-youwillsee/leetcode | 0111-Minimum-Depth-of-Binary-Tree/cpp_0111/Solution2.h | //
// Created by ooooo on 2019/11/4.
//
#ifndef CPP_0111_SOLUTION2_H
#define CPP_0111_SOLUTION2_H
#include "TreeNode.h"
class Solution {
public:
int minDepth(TreeNode *root) {
if (!root) return 0;
if (!root->left) return 1 + minDepth(root->right);
if (!root->right) return 1 + minDepth(roo... |
ooooo-youwillsee/leetcode | 1006-Clumsy Factorial/cpp_1006/Solution1.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2021/4/1 18:03
*/
#ifndef CPP_1006__SOLUTION1_H_
#define CPP_1006__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
class Solution {
public:
vector<string> ops = {"*", "/", "+", "-"};
void calc(stack<int> &s, string &op) {... |
ooooo-youwillsee/leetcode | 1657-Determine if Two Strings Are Close/cpp_1657/Solution1.h | /**
* @author ooooo
* @date 2021/1/24 18:00
*/
#ifndef CPP_1657__SOLUTION1_H_
#define CPP_1657__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
using namespace std;
class Solution {
public:
vector<int> calcCounts(string wo... |
ooooo-youwillsee/leetcode | 0810-Chalkboard XOR Game/cpp_0810/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2021/5/22 11:15
*/
#ifndef CPP_0810__SOLUTION1_H_
#define CPP_0810__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
bool xorGame(vector<int> &nums) {
if (nums.size() % 2 == 0) {
return true;
... |
ooooo-youwillsee/leetcode | 1170-Compare-Strings-by-Frequency-of-the-Smallest-Character/cpp_1170/Solution1.h | //
// Created by ooooo on 2020/2/2.
//
#ifndef CPP_1170__SOLUTION1_H_
#define CPP_1170__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <set>
using namespace std;
class Solution {
public:
int countFreq(string &s) {
char c = s[0];
int count = 1;
for (int i = 1; i < s.size(); ++i) {
i... |
ooooo-youwillsee/leetcode | lcof_026/cpp_026/Solution1.h | <reponame>ooooo-youwillsee/leetcode<gh_stars>10-100
//
// Created by ooooo on 2020/3/17.
//
#ifndef CPP_026__SOLUTION1_H_
#define CPP_026__SOLUTION1_H_
#include "TreeNode.h"
class Solution {
public:
bool isSameTree(TreeNode *node1, TreeNode *node2) {
if (!node2) return true;
if (!node1) return false;
... |
ooooo-youwillsee/leetcode | lcof_006/cpp_006/Solution3.h | //
// Created by ooooo on 2020/3/7.
//
#ifndef CPP_006__SOLUTION3_H_
#define CPP_006__SOLUTION3_H_
#include "ListNode.h"
/**
* O(n)
*/
class Solution {
public:
void dfs(ListNode *node) {
if (!node) return;
dfs(node->next);
ans.emplace_back(node->val);
}
vector<int> ans;
vector<int> reversePri... |
ooooo-youwillsee/leetcode | 0543-Diameter-of-Binary-Tree/cpp_0543/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/3.
//
#ifndef INC_0543_DIAMETER_OF_BINARY_TREE_SOLUTION1_H
#define INC_0543_DIAMETER_OF_BINARY_TREE_SOLUTION1_H
#include "TreeNode.h"
/**
* 所谓的直径 就是 节点个数 - 1
*/
class Solution {
public:
int max = INT_MIN;
int maxDepth(TreeNode *node) ... |
ooooo-youwillsee/leetcode | 0493-Reverse Pairs/cpp_0493/Solution1.h | /**
* @author ooooo
* @date 2020/11/28 09:11
*/
#ifndef CPP_0493__SOLUTION1_H_
#define CPP_0493__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
vector<long long> tmp;
int ans = 0;
void count(vector<int> &nums, int l, int mid, int r) {
int i = l, j = mid ... |
ooooo-youwillsee/leetcode | 0123-Best Time to Buy and Sell Stock III/cpp_0123/Solution1.h | /**
* @author ooooo
* @date 2021/1/9 12:23
*/
#ifndef CPP_0123__SOLUTION1_H_
#define CPP_0123__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* dp[i][j][k]
*/
class Solution {
public:
int maxProfit(vector<int> &prices) {
int n = prices.size();
int k = 2;
int v = -100001;
... |
ooooo-youwillsee/leetcode | 0137-Single Number II/cpp_0137/Solution1.h | /**
* @author ooooo
* @date 2021/4/30 20:02
*/
#ifndef CPP_0137__SOLUTION1_H_
#define CPP_0137__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
int singleNumber(vector<int> &nums) {
unordered_map<int, int> m;
for (auto num: nums) {
... |
ooooo-youwillsee/leetcode | lcof_053-2/cpp_053-2/Solution2.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/4/10.
//
#ifndef CPP_053_2__SOLUTION2_H_
#define CPP_053_2__SOLUTION2_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int missingNumber(vector<int> &nums) {
int len = nums.size();
for (int i = 0; i < ... |
ooooo-youwillsee/leetcode | 0781-Rabbits in Forest/cpp_0781/Solution1.h | <filename>0781-Rabbits in Forest/cpp_0781/Solution1.h
/**
* @author ooooo
* @date 2021/4/4 09:04
*/
#ifndef CPP_0781__SOLUTION1_H_
#define CPP_0781__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
int numRabbits(vector<int> &answers) {
... |
ooooo-youwillsee/leetcode | 0389-Find-the-Difference/cpp_0389/Solution3.h | //
// Created by ooooo on 2020/1/11.
//
#ifndef CPP_0389__SOLUTION3_H_
#define CPP_0389__SOLUTION3_H_
#include <iostream>
#include <unordered_map>
using namespace std;
/**
* 位运算 a^a = 0 ; a^0=a 最快
*/
class Solution {
public:
char findTheDifference(string s, string t) {
s += t;
int ch = 0;
for (au... |
ooooo-youwillsee/leetcode | 0452-Minimum Number of Arrows to Burst Balloons/cpp_0452/Solution1.h | /**
* @author ooooo
* @date 2020/11/23 20:23
*/
#ifndef CPP_0452__SOLUTION1_H_
#define CPP_0452__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int findMinArrowShots(vector<vector<int>> &points) {
if (points.empty()) return 0;
sort(points.begin(), points.e... |
ooooo-youwillsee/leetcode | 0538-Convert-BST-to_Greater-Tree/cpp_0538/Solution1.h | <filename>0538-Convert-BST-to_Greater-Tree/cpp_0538/Solution1.h<gh_stars>10-100
//
// Created by ooooo on 2020/1/3.
//
#ifndef CPP_0538_SOLUTION1_H
#define CPP_0538_SOLUTION1_H
#include "TreeNode.h"
#include <vector>
/**
* vector 存放所有的TreeNode节点(inOrder),倒序遍历。
*/
class Solution {
public:
void inOrder(TreeNode ... |
ooooo-youwillsee/leetcode | 1736-Latest Time by Replacing Hidden Digits/cpp_1736/Solution1.h | /**
* @author ooooo
* @date 2021/2/28 13:09
*/
#ifndef CPP_1736__SOLUTION1_H_
#define CPP_1736__SOLUTION1_H_
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <vector>
#include <numeric>
using namespace std;
class Solution {
public:
string max... |
ooooo-youwillsee/leetcode | 0367-Valid-Perfect-Square/cpp_0367/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/17.
//
#ifndef CPP_0367__SOLUTION2_H_
#define CPP_0367__SOLUTION2_H_
#include <iostream>
using namespace std;
class Solution {
public:
bool isPerfectSquare(int num) {
if (num < 2) return true;
long x = num / 2;
while (x * x > num) {
x = (x + num... |
ooooo-youwillsee/leetcode | 0007-Reverse Integer/cpp_0007/Solution1.h | /**
* @author ooooo
* @date 2021/5/3 18:23
*/
#ifndef CPP_0007__SOLUTION1_H_
#define CPP_0007__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int reverse(int x) {
int sum = 0;
while (x) {
if (sum < INT_MIN / 10 || sum > INT_MAX / 10) {
return 0;
... |
ooooo-youwillsee/leetcode | 1078-Occurrences-After-Bigram/cpp_1078/Solution1.h | //
// Created by ooooo on 2020/1/16.
//
#ifndef CPP_1078__SOLUTION1_H_
#define CPP_1078__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
vector<string> split(string s) {
vector<string> ans;
int i = 0, j = s.find_first_of(" ", i);
while (j != -1) {
... |
ooooo-youwillsee/leetcode | lcof_040/cpp_040/Solution3.h | //
// Created by ooooo on 2020/3/25.
//
#ifndef CPP_040__SOLUTION3_H_
#define CPP_040__SOLUTION3_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int partition(int i, int j, vector<int> &arr) {
int k = i, item = arr[i];
for (int p = i + 1; p <= j; ++p) {
if (ar... |
ooooo-youwillsee/leetcode | 0383-Ransom-Note/cpp_0383/Solution2.h | <filename>0383-Ransom-Note/cpp_0383/Solution2.h
//
// Created by ooooo on 2020/1/25.
//
#ifndef CPP_0383__SOLUTION2_H_
#define CPP_0383__SOLUTION2_H_
#include <iostream>
#include <unordered_map>
using namespace std;
class Solution {
public:
bool canConstruct(string ransomNote, string magazine) {
if (ransomNot... |
ooooo-youwillsee/leetcode | 0146-LRU-Cache/cpp_0146/Solution2.h | //
// Created by ooooo on 2020/2/18.
//
#ifndef CPP_0146__SOLUTION2_H_
#define CPP_0146__SOLUTION2_H_
#include <iostream>
#include <unordered_map>
using namespace std;
/**
* 要删除的节点在头结点
*/
class LRUCache {
private:
struct Node {
Node *prev, *next;
int key, value;
Node() {}
Node(int key, int valu... |
ooooo-youwillsee/leetcode | 0037-Sudoku-Solver/cpp_0037/Solution2.h | /**
* @author ooooo
* @date 2020/9/15 11:13
*/
#ifndef CPP_0037__SOLUTION2_H_
#define CPP_0037__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
class Solution2 {
public:;
vector<unordered_set<char>> groups = vector<unordered_set<char>>(9);
vector<unordered_set... |
ooooo-youwillsee/leetcode | 0134-Gas Station/cpp_0134/Solution1.h | /**
* @author ooooo
* @date 2020/11/19 09:02
*/
#ifndef CPP_0134__SOLUTION1_H_
#define CPP_0134__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int canCompleteCircuit(vector<int> &gas, vector<int> &cost) {
int i = 0, n = gas.size();
while (i < n) {
int ... |
ooooo-youwillsee/leetcode | 0953-Verifying-an-Alien-Dictionary/cpp_0953/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/1/16.
//
#ifndef CPP_0953__SOLUTION1_H_
#define CPP_0953__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
bool check(string s1, string s2, int m[]) {
// 比较最小的长度
for (int i = 0; i < min(s1.si... |
ooooo-youwillsee/leetcode | lcof_035/cpp_035/Node.h | <gh_stars>10-100
//
// Created by ooooo on 2020/3/22.
//
#ifndef CPP_035__NODE_H_
#define CPP_035__NODE_H_
#include <iostream>
using namespace std;
class Node {
public:
int val;
Node *next;
Node *random;
Node(int _val) {
val = _val;
next = NULL;
random = NULL;
}
};
#endif //CPP_035__NODE_H_
|
ooooo-youwillsee/leetcode | 0589-N-ary-Tree-Preorder-Traversal/cpp_0589/Solution2.h | <gh_stars>10-100
//
// Created by ooooo on 2020/1/3.
//
#ifndef CPP_0589_SOLUTION2_H
#define CPP_0589_SOLUTION2_H
#include "Node.h"
#include <stack>
class Solution {
public:
vector<int> preorder(Node *root) {
if (!root) return {};
vector<int> res;
stack<Node *> s;
s.push(root);
... |
ooooo-youwillsee/leetcode | 0363-Max Sum of Rectangle No Larger Than K/cpp_0363/Solution1.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2021/4/22 17:12
*/
#ifndef CPP_0363__SOLUTION1_H_
#define CPP_0363__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <set>
using namespace std;
class Solution {
public:
int maxSumSubmatrix(vector<vector<int>> &matrix, int k) {
int m = matrix.size(), n ... |
ooooo-youwillsee/leetcode | 0220-Contains Duplicate III/cpp_0220/Solution1.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2021/4/17 09:59
*/
#ifndef CPP_0220__SOLUTION1_H_
#define CPP_0220__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <set>
using namespace std;
class Solution {
public:
bool containsNearbyAlmostDuplicate(vector<int> &nums, int k, int t... |
ooooo-youwillsee/leetcode | 0001-Two-Sum/cpp_0001/Solution2.h | #include <vector>
#include <iostream>
#include <map>
using namespace std;
/**
* hash表
*/
class Solution2 {
public:
static vector<int> twoSum(vector<int> &nums, int target) {
vector<int> result;
map<int, int> map;
for (int i = 0; i < nums.size(); ++i) {
map[nums[i]] = i;
... |
ooooo-youwillsee/leetcode | 1160-Find-Words-That-Can-Be-Formed-by-Characters/cpp_1160/Solution1.h | //
// Created by ooooo on 2020/1/16.
//
#ifndef CPP_1160__SOLUTION1_H_
#define CPP_1160__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
int countCharacters(vector<string> &words, string chars) {
unordered_map<char, int> m;
for_each... |
ooooo-youwillsee/leetcode | 0146-LRU-Cache/cpp_0146/Solution1.h | <filename>0146-LRU-Cache/cpp_0146/Solution1.h
//
// Created by ooooo on 2020/2/18.
//
#ifndef CPP_0146__SOLUTION1_H_
#define CPP_0146__SOLUTION1_H_
#include <iostream>
#include <unordered_map>
using namespace std;
/**
* 要删除的节点在尾节点
*/
class LRUCache {
private:
struct Node {
Node *prev, *next;
int key, v... |
ooooo-youwillsee/leetcode | 0309-Best-Time-to-Buy-and-Sell-Stock-with-Cooldown/cpp_0309/Solution1.h | //
// Created by ooooo on 2020/2/25.
//
#ifndef CPP_0309__SOLUTION1_H_
#define CPP_0309__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* 第 i 天, j (0:不持有一股, 1:持有一股)
*
* dp[i][0] = max(dp[i-1][0], dp[i-1][1] + p)
* dp[i][1] = max(dp[i-1][1], dp[i-2][0] - p)
*/
class Solution {
pub... |
ooooo-youwillsee/leetcode | lcof_010-1/cpp_010-1/Solution1.h | <reponame>ooooo-youwillsee/leetcode
//
// Created by ooooo on 2020/3/8.
//
#ifndef CPP_010_1__SOLUTION1_H_
#define CPP_010_1__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* F(N) = F(N - 1) + F(N - 2)
*
* recursion timeout (有重复计算)
* O(2^n)
*/
class Solution {
public:
long dfs(i... |
ooooo-youwillsee/leetcode | 0621-Task Scheduler/cpp_0621/Solution2.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2020/12/5 12:49
*/
#ifndef CPP_0621__SOLUTION2_H
#define CPP_0621__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
/**
*
*/
class Solution {
public:
int leastInterval(vector<char> &tasks, int n) {
vector<int> task_counts... |
ooooo-youwillsee/leetcode | 0765-Couples Holding Hands/cpp_0765/Solution1.h | <gh_stars>10-100
/**
* @author ooooo
* @date 2021/2/14 09:42
*/
#ifndef CPP_0765__SOLUTION1_H_
#define CPP_0765__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
// dfs , 可以优化
// 理解最重要的一点 比如 [0,x,1,z], 要使0,1在一起的话,就是[0,1,x,z]或者[z,x,1,0]
// 上述的这两种情况,x,z只是相对位置发生了改变,而实际的交换次数并没有改变
class Soluti... |
ooooo-youwillsee/leetcode | 1807-Evaluate the Bracket Pairs of a String/cpp_1807/Solution1.h | /**
* @author ooooo
* @date 2021/4/4 08:31
*/
#ifndef CPP_1807__SOLUTION1_H_
#define CPP_1807__SOLUTION1_H_
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <stack>
#include <numeric>
#include <queue>
using namespace std;
class Solution {
public:
... |
ooooo-youwillsee/leetcode | 0117-Populating-Next-Right-Pointers-in-Each-Node-II/cpp_0117/Node.h | <reponame>ooooo-youwillsee/leetcode
/**
* @author ooooo
* @date 2020/9/28 09:19
*/
#ifndef CPP_0117__NODE_H_
#define CPP_0117__NODE_H_
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
class Node {
public:
int val;
Node *left;
Node *right;
Node *next;
Node() : val(0), left(NULL)... |
ooooo-youwillsee/leetcode | 1562-Find Latest Group of Size M/cpp_1562/Solution2.h | /**
* @author ooooo
* @date 2020/12/12 20:27
*/
#ifndef CPP_1562__SOLUTION2_H_
#define CPP_1562__SOLUTION2_H_
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
public:
int findLatestStep(vector<int> &arr, int m) {
int n = arr.size();
if (m == n) return n;... |
ooooo-youwillsee/leetcode | 0145-Binary-Tree-Postorder-Traversal/cpp_0145/Solution2.h | /**
* @author ooooo
* @date 2020/9/29 09:21
*/
#ifndef CPP_0145__SOLUTION2_H_
#define CPP_0145__SOLUTION2_H_
#include "TreeNode.h"
class Solution {
public:
vector<int> postorderTraversal(TreeNode *root) {
vector<int> ans;
if (!root) return ans;
stack<TreeNode *> s;
TreeNode *cur = root, *prev = nullptr... |
ooooo-youwillsee/leetcode | 0322-Coin-Change/cpp_0322/Solution1.h | //
// Created by ooooo on 2020/2/26.
//
#ifndef CPP_0322__SOLUTION1_H_
#define CPP_0322__SOLUTION1_H_
#include <iostream>
#include <vector>
using namespace std;
/**
* p = coins[j] ==> dp[i] = min(dp[i],dp[i-p] + 1)
*/
class Solution {
public:
int coinChange(vector<int> &coins, int amount) {
vector<int> d... |
ooooo-youwillsee/leetcode | lcof_009/cpp_009/Solution1.h | <filename>lcof_009/cpp_009/Solution1.h<gh_stars>10-100
//
// Created by ooooo on 2020/3/8.
//
#ifndef CPP_009__SOLUTION1_H_
#define CPP_009__SOLUTION1_H_
#include <iostream>
#include <stack>
using namespace std;
class CQueue {
private:
stack<int> s1, s2;
public:
CQueue() {
}
void appendTail(int value) {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.