This file contains hidden or 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
// Reference: https://developers.google.com/youtube/v3/quickstart/nodejs?hl=ja | |
// This program loads client secrets from a local file (~/.credentials/youtube-nodejs-quickstart.json). | |
// To set up the client secret, | |
// 1. visit https://console.cloud.google.com/. | |
// 2. Enable YouTube API. | |
// 3. Create an OAuth 2.0 client ID for a "Desktop Application". | |
// 4. Download the client secret file as a JSON file. | |
const fs = require('fs'); |
This file contains hidden or 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
// Reference: https://developers.google.com/youtube/v3/quickstart/nodejs?hl=ja | |
// This program loads client secrets from a local file (~/.credentials/youtube-nodejs-quickstart.json). | |
// To set up the client secret, | |
// 1. visit https://console.cloud.google.com/. | |
// 2. Enable YouTube API. | |
// 3. Create an OAuth 2.0 client ID for a "Desktop Application". | |
// 4. Download the client secret file as a JSON file. | |
const fs = require('fs'); |
This file contains hidden or 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 numIslands(vector<vector<char>>& grid) { | |
if (grid.empty() || grid[0].empty()) { | |
return 0; | |
} | |
vector<vector<bool>> checked(grid.size(), vector<bool>(grid[0].size())); | |
int islands = 0; | |
for (int y = 0; y < grid.size(); y++) { | |
for (int x = 0; x < grid[0].size(); x++) { |
This file contains hidden or 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 search(vector<int>& nums, int target) { | |
return nums.empty() ? -1 : find(nums, target, 0, nums.size() - 1); | |
} | |
int find(const vector<int>& nums, int target, int start, int end) { | |
// cout << start << " " << end << endl; | |
if (start == end) { | |
return nums[start] == target ? start : -1; |
This file contains hidden or 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 myAtoi(string str) { | |
int pos = 0; | |
while (str[pos] == ' ' && str[pos] != NULL) { | |
pos++; | |
} | |
if (str[pos] == NULL) { | |
return 0; | |
} |
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
int generate_and_count(long long current, long long target, bool has3, bool has5, bool has7) { | |
int answer = 0; | |
if (current > target) { | |
return answer; | |
} | |
if (has3 && has5 && has7) { | |
answer++; |
This file contains hidden or 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
#include <hash_map> | |
int solve(const vector<int>& A, | |
const vector<int>& B, | |
const vector<int>& C, | |
const vector<int>& D) { | |
int count = 0; | |
hash_map<int, int> AB = create_pairs(A, B); | |
hash_map<int, int> CD = create_pairs(C, D); | |
for (const auto& pair : AB) { |
This file contains hidden or 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
#include <map> | |
#include <set> | |
using namespace std; | |
class GeometricProgressions { | |
public: | |
// decompose(120, &result) -> result will be {2:3, 3:1, 5:1}, meaning 2**3 * 3**1 * 5**1. | |
void decompose(int n, map<int, int>* result) { | |
// sqrt(500000000) < 22361 |