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
long arrayManipulation(int n, vector<vector<int>> queries) { | |
vector<int> arr(n / 2, 0); | |
for (auto i: queries) { | |
arr[i[0] - 1] += i[2]; | |
if (i[1] != arr.size()) { | |
continue; | |
} | |
} |
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
void checkMagazine(vector<string> magazine, vector<string> note) { | |
if(magazine.size() < 1 || magazine.size() > 30000){ | |
std::cout << "No\n"; | |
return; | |
} | |
if(note.size() < 1 || note.size() > 30000){ | |
std::cout << "No\n"; | |
return; | |
} | |
map<string, int> words; |
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
string twoStrings(string s1, string s2) { | |
set<char> f(s1.begin(), s1.end()); | |
std::cout << s1 << "\n" << s2 << "\n\n"; | |
for(auto i : s2){ | |
std::cout << i << "\n"; | |
auto ret = f.insert(i); | |
if(ret.second == false){ |
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
vector<int> freqQuery(vector<vector<int>> queries) { | |
map<int, int> freqStore, freqKey; | |
vector<int> output; | |
int counter = 0; | |
for(size_t n = 0; n < queries.size(); n++){ | |
counter = queries[n][0] % 3; | |
if(counter == 1){ | |
freqKey[freqStore[queries[n][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
void countSwaps(vector<int> a) { | |
int n = a.size(); | |
int swapCounter = 0; | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < n - 1; j++) { | |
if (a[j] > a[j + 1]) { | |
swap(a[j], a[j + 1]); | |
swapCounter++; |
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
int maximumToys(vector<int> prices, int k) { | |
sort(prices.begin(), prices.end()); | |
int count = 0; | |
int totalSum = 0; | |
while (totalSum < k) { | |
totalSum = totalSum + prices[count]; | |
count++; | |
} | |
return count - 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 Checker{ | |
public: | |
// complete this method | |
static int comparator(Player a, Player b) { | |
if (a.score < b.score) { | |
return -1; | |
} else if (a.score > b.score) { | |
return 1; | |
} else if(a.name > b.name){ | |
return -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
// sdl_opengl.cpp : This file contains the 'main' function. Program execution begins and ends there. | |
// | |
#include <iostream> | |
#include <SDL2/SDL.h> | |
#include <SDL2/SDL_surface.h> | |
#include <SDL2/SDL_render.h> | |
#include <SDL2/SDL_opengl.h> | |
#include <boost/geometry.hpp> |
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
// sdl_opengl.cpp : This file contains the 'main' function. Program execution begins and ends there. | |
// | |
#include <iostream> | |
#include <SDL2/SDL.h> | |
#include <SDL2/SDL_surface.h> | |
#include <SDL2/SDL_render.h> | |
#include <SDL2/SDL_opengl.h> | |
#include <boost/geometry.hpp> |
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> | |
#include <SDL2/SDL.h> | |
#include <SDL2/SDL_surface.h> | |
#include <SDL2/SDL_render.h> | |
#include <SDL2/SDL_opengl.h> | |
#include <boost/geometry.hpp> | |
#include <boost/geometry/geometries/register/point.hpp> | |
#include <boost/geometry/geometries/register/box.hpp> |