Implementations C++ #include <cstddef> #include <vector> template <typename T, typename Cmp = std::less<T>> class Heap { private: std::vector<T> array_; Cmp comp_; // INFO: you don't need a size // INFO: it's complete b tree in the sense that you FILL the // r...
Implementations C++ #include <cstddef> template <typename T> class LinkedList { private: // INFO: only C needs struct Node like creation, in cpp can just do Node // so you never need that typedef thing struct Node { Node *next; Node *prev; T value; // copy ctors on T expected, fails othe...
general ideas for what I notice and feel while solving a problem the solution is not the code, implementation is not the challenge here ( well not at this stage ).
Backtracking Core Idea Backtracking is controlled brute force: dfs(state): if state is complete: record answer return for choice in valid choices from state: choose dfs(next state) undo Common Shapes Pick Or Skip Use when every element has exactly two choices: take it or leave it.
Over a state Use this when recursion places something into a row, cell, grid path, bucket, or slot while constraints decide whether the choice is legal.