摘要:
bool checkSame(std::string a, std::string b) { constexpr int size = 145; std::vector<int> count(145); std::for_each(a.cbegin (), a.cend (), [&](char c 阅读全文
摘要:
class ThreadRAII { public: // whether join or detach should be called, // when a this object is destroyed. enum class DtorAction { join, detach }; Thr 阅读全文
摘要:
class Node; using NodePtr = std::unique_ptr<Node>; class Node { public: int value; NodePtr next = nullptr; explicit Node(int value_ = 0): value(value_ 阅读全文
摘要:
int convert(char buf[], int value) { constexpr char digits[] = {'9', '8', '7', '6', '5', '4', '3', '2', '1', '0', '1', '2', '3', '4', '5', '6', '7', ' 阅读全文
摘要:
struct Node { int value = 0; Node* next = nullptr; Node(int value_) : value(value_) {} }; Node* createLinkList(const std::vector<int>& data) { if (dat 阅读全文
摘要:
最基本的快排: int partition(int arr[], int l, int r) { int k = l; int pivot = arr[r]; for (int i = l; i != r; ++i){ if (arr[i] < pivot){ std::swap(arr[i], a 阅读全文
摘要:
typedef std::list List;typedef std::map Map;Map getAnagrams(List& input){ Map result; for (const auto& s : input){ auto key = s; ... 阅读全文
摘要:
#include <iostream> #include <vector> #include <string> #include <mysql.h> using namespace std; int main() { ios::sync_with_stdio (false); MYSQL conne 阅读全文
摘要:
void leftRoutate(std::string& s, size_t offset){ auto reverse = [&](size_t begin, size_t end) { --end; while (begin <= end){ ... 阅读全文
摘要:
size_t LCS(const std::string& x, const std::string& y){ if (x.empty () || y.empty ()){ return 0; } const size_t width = x.length () +... 阅读全文