This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by fpdjsns | |
// Copyright © 2019 fpdjsns. All rights reserved. | |
// | |
#include<iostream> | |
#include<vector> | |
#include<algorithm> | |
#include<string> | |
#include<queue> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by fpdjsns | |
// Copyright © 2019 fpdjsns. All rights reserved. | |
// | |
#include<iostream> | |
#include<vector> | |
#include<algorithm> | |
#include<string> | |
#define INF 1e12 | |
typedef long long LL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int longestOnes(vector<int>& A, int K) { | |
int answer = 0; | |
queue<int> zeroQ; | |
int start = 0; | |
for(int end=0;end<A.size();end++){ | |
if(A[end] == 0) | |
zeroQ.push(end); | |
if(!zeroQ.empty() && zeroQ.size() > K){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by fpdjsns | |
// Copyright © 2019 fpdjsns. All rights reserved. | |
// | |
#include<iostream> | |
#include<vector> | |
#include<algorithm> | |
#include<string> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int findJudge(int N, vector<vector<int>>& trust) { | |
vector<int> cnt(N+1, 0); | |
for(int i=0;i<trust.size();i++){ | |
int from = trust[i][0]; | |
int to = trust[i][1]; | |
cnt[to]++; | |
cnt[from] = -N; // The town judge trusts nobody. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by fpdjsns | |
// Copyright © 2019 fpdjsns. All rights reserved. | |
// | |
/* | |
* 시간복잡도 : O(N) | |
*/ | |
#include<iostream> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
private: | |
const int EMPTY = 0; | |
const int FRESH = 1; | |
const int ROTTEN = 2; | |
struct Cell { | |
int x; | |
int y; | |
int minutes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 { |