Skip to content

Instantly share code, notes, and snippets.

View TakefumiYamamura's full-sized avatar

Takefumi Yamamura TakefumiYamamura

View GitHub Profile
#include <iostream>
#include <assert.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <climits>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <set>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <set>
class Solution {
public:
vector<int> productExceptSelf(vector<int>& nums) {
vector<int> ans = vector<int>(nums.size(), 1);
int front = 1;
int back = 1;
for (int i = 0; i < nums.size(); ++i)
{
front *= nums[i];
back *= nums[nums.size() - i - 1];
#include <vector>
#include <iostream>
using namespace std;
struct Box
{
int w, h, d;
bool operator < (cost Box& b) const {
if(w == b.w){
#include <iostream>
#include <string>
using namespace std;
void printDoubleFromBinary(string binary){
double ans = 0;
double tmp = 1.0;
for (int i = 0; i < binary.length(); ++i)
{
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Screen
{
private:
int size;
#include <iostream>
#include <string>
using namespace std;
void print_bit(int n) {
string ans = "";
while(n > 0) {
if(n & 1) {
ans = "1" + ans;
#include <iostream>
#include <algorithm>
using namespace std;
int best_reverse_len(int n){
if(n == 0) return 1;
int cur = 0;
int before = 0;
int ans = 0;
class Solution {
private:
unordered_map<string, vector<string> > trie;
unordered_map<int, vector<string> > um;
vector<vector<string> > ans;
public:
vector<vector<string>> wordSquares(vector<string>& words) {
for(auto x : words) um[x.length()].push_back(x);
for (auto itr = um.begin(); itr != um.end(); ++itr)
{