Skip to content

Instantly share code, notes, and snippets.

CK, Lee s4553711

Block or report user

Report or block s4553711

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View vmsplice_test.c
#include <zlib.h>
#include <time.h>
#include <stdio.h>
#include <stdbool.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <unistd.h>
#include <inttypes.h>
#include "kseq.h"
#include "kstring.h"
View timeline-iostat.r
library(ggplot2)
library(scales)
library(ggpubr)
k = read.csv('iostat.tsv')
k$datetime <- as.POSIXct(k$time, origin="1970-01-01", tz="GMT")
s1 <- ggplot(k, aes(datetime)) +
geom_line(aes(y = rs, colour="rs"), alpha=0.4, size=1) +
geom_line(aes(y = ws, colour="ws"), alpha=0.4, size=1) +
View 172.cpp
class Solution {
public:
int trailingZeroes(int n) {
if (n < 5) return 0;
int count = 0;
while(n >= 5) {
count += floor(n/5);
n /= 5;
}
return count;
View 712.cpp
vector<vector<int> > C(s1.length() + 1, vector<int>(s2.length() + 1, 0));
// initial
for (int i = 1; i < s2.length() + 1; ++i) {
C[0][i] = C[0][i - 1] + s2[i - 1];
}
for (int i = 1; i < s1.length() + 1; ++i) {
C[i][0] = C[i - 1][0] + s1[i - 1];
}
for (int i = 1; i < s1.length() + 1; ++i) {
for (int j = 1; j < s2.length() + 1; ++j) {
View 413.cpp
class Solution {
public:
int numberOfArithmeticSlices(vector<int>& A) {
int count = 0;
int added = 0;
int n = A.size();
for(int i = 2; i < n; i++) {
if (A[i-1] - A[i] == A[i-2] - A[i-1]) {
count += ++added;
} else {
View 7.cpp
class Solution {
public:
int reverse(int x) {
int rev = 0;
while (x != 0) {
int pop = x % 10;
x /= 10;
if (rev > INT_MAX/10 || rev == INT_MAX/10 && pop > 7) return 0;
if (rev < INT_MIN/10 || rev == INT_MIN/10 && pop < -8) return 0;
rev = rev * 10 + pop;
View 647.cpp
class Solution {
public:
int countSubstrings(string s) {
int ans = 0;
for (int i = 0; i < s.length();i++) {
ans += count(s, i, i);
ans += count(s, i, i+1);
}
return ans;
}
View 338.cpp
class Solution {
public:
vector<int> countBits(int num) {
vector<int> res = vector<int>(num+1, 0);
for(int i = 1; i <= num; i++) {
res[i] = res[i >> 1] + (i & 1);
}
return res;
}
};
View 638.cpp
class Solution {
public:
int shoppingOffers(vector<int>& price, vector<vector<int>>& special, vector<int>& needs) {
int res = inner_product(price.begin(), price.end(), needs.begin(), 0);
for (auto offer: special) {
vector<int> r = helper(offer, needs);
if (r.empty()) continue;
res = min(res, shoppingOffers(price, special, r) + offer.back());
}
return res;
View 473.cpp
class Solution {
public:
bool makesquare(vector<int>& nums) {
if (nums.empty() || nums.size() < 4) return false;
int sum = accumulate(nums.begin(), nums.end(), 0);
if (sum % 4 != 0) return false;
int n = nums.size(), all = (1 << n) - 1, target = sum/4;
vector<int> masks, validHalf(1<<n, false);
for(int i = 0; i < all; i++) {
int curSum = 0;
You can’t perform that action at this time.