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
//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; |
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
//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; |
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
//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 { |