Skip to content

Instantly share code, notes, and snippets.

@joe-cai
joe-cai / wordProduct.cpp
Last active October 18, 2015 18:46
Maximal Product of Two Non-overlapping Words in a Dictionary
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
bitset<26> to_bits(const string& word) {
bitset<26> ans;
for (int i = 0; i < word.size(); i++)
if (!ans[word[i] - 'a'])
ans.flip(word[i] - 'a');
@joe-cai
joe-cai / maxAmp.cpp
Last active September 18, 2016 01:07
Maximal Amplitude of a Binary Tree
class TreeNode {
int val;
TreeNode* left;
TreeNode* right;
TreeNode(int val_) : val(val_) {}
};
class Solution {
int ans = 0;
int maxAmp(struct TreeNode* root) {
@joe-cai
joe-cai / lrs.cpp
Last active September 23, 2015 23:13
Longest Repeating Subsequence
// geeksforgeeks
// Longest Repeating Subsequence
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
using namespace std;
int main() {