Skip to content

Instantly share code, notes, and snippets.

View statulr's full-sized avatar
🍵
matcha is genuinly yummy

robb statulr

🍵
matcha is genuinly yummy
View GitHub Profile
@statulr
statulr / solution.c
Created January 5, 2024 17:29
Longest Increasing Subsequence (5 ms)
//https://leetcode.com/problems/longest-increasing-subsequence/submissions/1137805195
#include <stdint.h>
uint32_t binarySearch(int32_t* tails, uint32_t size, int32_t target) {
uint32_t left = 0, right = size;
while (left < right) {
uint32_t mid = left + (right - left) / 2;
if (tails[mid] < target) {
left = mid + 1;
} else {
@statulr
statulr / solution.c
Last active November 30, 2023 16:05
leetcode2148 (Faster than 100%)
//https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero/submissions/1109638560/
#include <stdio.h>
unsigned int minimumOneBitOperations(unsigned int n) {
uint32_t result = 0;
while (n) {
result ^= n;
n >>= 1;
}
return result;
@statulr
statulr / solution.c
Last active November 28, 2023 19:40
leetcode2147 (24MS Beats 100% of Users)
//https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor/submissions/1108244532/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
const uint32_t modulo = 1000000007;
uint64_t modularExponentiation(uint64_t base, uint64_t exponent, uint64_t mod) {
uint64_t result = 1;
base %= mod;