Skip to content

Instantly share code, notes, and snippets.

View Jefferson-Aggor's full-sized avatar

Jefferson Aggor Jefferson-Aggor

View GitHub Profile
@Jefferson-Aggor
Jefferson-Aggor / CountNumbersToRight.js
Created July 23, 2025 11:52
This is an implementation of counting the smaller numbers
const countSmallerToRight = (nums) => {
// Helper: Binary Indexed Tree O(nlog(n))
function BIT(size) {
const tree = new Array(size + 1).fill(0);
return {
// Update the tree: add 'delta' at the given index
update(index, delta) {
index += 1;
while (index < tree.length) {
tree[index] += delta;