Skip to content

Instantly share code, notes, and snippets.

View xiaosuo's full-sized avatar
🔒

Changli Gao xiaosuo

🔒
View GitHub Profile
@xiaosuo
xiaosuo / lcs.cc
Last active May 2, 2017 02:21
lcs
#include <iostream>
#include <string>
using namespace std;
static ssize_t *memory = nullptr;
size_t lcs(const string &s1, const std::string &s2, size_t i1, size_t i2) {
if (!memory) {
size_t size = (s1.size() + 1) * (s2.size() + 1);
class Defer {
public:
explicit Defer(std::function<void()> func) : func_(func) {}
~Defer() { func_(); }
private:
Defer(const Defer &) = delete;
Defer& operator=(const Defer &) = delete;
std::function<void()> func_;
};