> For the complete documentation index, see [llms.txt](https://abhyas-kanaujia.gitbook.io/lb-dsa-notes-and-homework-abhyas/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://abhyas-kanaujia.gitbook.io/lb-dsa-notes-and-homework-abhyas/functions.md).

# Functions

### String

| Function                      | Remark                                                | Time Complexity |
| ----------------------------- | ----------------------------------------------------- | --------------- |
| `int stoi(string str)`        | Convert Given String to Integer                       | O(n)            |
| `stol()`, `stoll()`, `stod()` | Convert Given string to `long`, `long long`, `double` | O(n)            |
|                               |                                                       |                 |
|                               |                                                       |                 |

### Algorithm

<table><thead><tr><th width="311.3333333333333">Function</th><th width="283.30927835051546">Remark</th><th>Time Complexity</th></tr></thead><tbody><tr><td><code>void swap(any &#x26;a, any &#x26;b)</code></td><td>Sawps two variable of any type; both same type. Takes value by reference. Very fast. </td><td>O(1) for non array. O(n) for array.</td></tr><tr><td><code>any &#x26;min(any &#x26;a, any &#x26;b)</code> also <code>max()</code></td><td>Returns the minimum of <code>a</code> and <code>b</code>. If both are equivalent then return <code>a</code>.</td><td>O(1)</td></tr><tr><td><code>any &#x26;min(any &#x26;a, any &#x26;b, Compare comp)</code> also <code>max()</code></td><td>Same as normal min but takes a custom comparator funciton. </td><td>O(1)</td></tr><tr><td><code>void sort(it first, it last)</code></td><td>Sorts the elements in the range <code>[first,last)</code> into ascending order.</td><td>O(N * log N)</td></tr><tr><td><code>void sort(it first, it last, Compare comp)</code></td><td>Same as normal sort but takes a comparator function.</td><td>O(N * log N)</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

**Comparator Function**: A boolean function that takes two input of same type and reutrn true when the first element is found to be smaller than the second element.&#x20;
