This is a manual that introduces some examples of code for classic algorithm problems, suitable for writing on paper.
This document serves as a cheat sheet for competitive programming, specifically focusing on the ACM (Association for Computing Machinery) context. It provides quick reference material for C and C++ standard library functions, including string manipulation, memory management, and input/output operations.
The guide covers a wide range of topics essential for algorithmic problem solving, including linear lists, stacks, queues, and various search algorithms like KMP and Rabin-Karp. It also details data structures such as trees (Morris Traversal), tries, and graphs, along with sorting and searching algorithms like Merge Sort, Quick Sort, and Dijkstra's algorithm.
It returns the full haystack string. The code checks for an empty needle first and returns the haystack cast to char*.
It requires that both to and from are not NULL, which it checks with an assert at the start of the function.
It advances a pointer s from str until it reaches the terminating character, then returns the difference s - str.