This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdexcept> | |
#include <functional> | |
struct Node { | |
int data; | |
Node *next; | |
}; | |
using fn = std::function<void(Node*)>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stack> | |
#include <string> | |
#include <cctype> | |
#include <cstdlib> | |
using std::stack; | |
using std::string; | |
int evaluateExpr(const char *op, stack<int> &tokens) { | |
int b = tokens.top(); tokens.pop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdexcept> | |
class Queue { | |
private: | |
int length = 0; | |
int front = -1; | |
int rear = -1; | |
int *queue = nullptr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getAbortable () { | |
let controller | |
return { | |
fetch: (url, opts) => { | |
controller = new AbortController() | |
return fetch(url, Object.assign(opts, { | |
signal: controller.signal | |
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debounceFetch (fn, delay, onCancel = () => {}) { | |
let timer = 0, isFetching = false | |
return function (...args) { | |
clearTimeout(timer) | |
if (isFetching) { | |
onCancel() | |
isFetching = false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdexcept> | |
struct Node { | |
int data; | |
Node* next; | |
}; | |
class Queue { | |
private: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createElement (name, attrs, ...children) { | |
name = name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase() | |
const $el = document.createElement(name) | |
if (attrs) { | |
for (const [attr, val] of Object.entries(attrs)) | |
$el.setAttribute(attr, val) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const id = 'RenameChunkPlugin' | |
module.exports = class RenameChunkPlugin { | |
constructor (filenameMap) { | |
this.filenameMap = filenameMap | |
} | |
apply (compiler) { | |
compiler.hooks.thisCompilation.tap(id, compilation => { | |
compilation.hooks.optimizeChunkModules.tap(id, chunks => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void merge(const int l, const int m, const int h, int* arr) { | |
const int len = h - l + 1; | |
int* const temp = new int[len]; | |
int i = l; | |
int j = m + 1; | |
int k = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void swap (int* arr, int i, int j) { | |
const int temp = arr[i]; | |
arr[i] = arr[j]; | |
arr[j] = temp; | |
} | |
void heapify (int* arr, int max, int root) { | |
const int left = root * 2; |