Skip to content

Instantly share code, notes, and snippets.

View z0marlin's full-sized avatar
👀
Staring at random code

Aditya Jain z0marlin

👀
Staring at random code
View GitHub Profile
@z0marlin
z0marlin / week1.cpp
Created October 4, 2018 13:19
Webclub codebuddy week1 odd sem 2018
string s;
vector<string> ans;
void myFunc(int n,int o,int c){
if(o+c==2*n){
ans.push_back(s);
return;
}
if(o<n){
s.push_back('(');
myFunc(n,o+1,c);
@z0marlin
z0marlin / week2.cpp
Last active October 14, 2018 06:57
Codebuddy week2 solution.
int pivot(const vector<int> &A){
int l=0;
int r=A.size()-1;
int mid;
while(l<r){
mid=(r-l)/2+l;
if(mid>l && A[mid-1]>A[mid]){
return mid;
}
if(mid<r && A[mid+1]<A[mid]){
@z0marlin
z0marlin / week3.py
Created October 20, 2018 08:23
WEC codebuddy week3 solution
class Solution:
def singleNumber(self, A):
res=0
count=0
for j in range(64):
count = 0
for i in A :
if 1<<j & i :
count+=1
if count%3 != 0 :
@z0marlin
z0marlin / week4.cpp
Created October 28, 2018 10:59
WEC Codebuddy week4 sem-3 solution.
int Solution::black(vector<string> &A) {
int n=A.size(),m=A[0].size(),count=0,x,y;
queue<pair<int,int>> q;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(A[i][j]=='X'){
count++;
q.push(make_pair(i,j));
while(!q.empty()){
x=q.front().first;
@z0marlin
z0marlin / week5.cpp
Created November 3, 2018 16:13
WEC Codebuddy week5 3rd sem solution
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
stack<TreeNode*> s;
@z0marlin
z0marlin / w1s4_1.cpp
Created January 14, 2019 13:36
WEC Codebuddy Sem-4 Week-1 question-1 solution.
#define SUM(i) (i >= 0 ? sum[i] : 0)
class Solution {
public:
int minSubArrayLen(int s, vector<int>& nums) {
int i = 0, j = 0, len = nums.size(), min_len = INT_MAX;
if(len == 0)
return 0;
int sum[len];
sum[0] = nums[i];
for(i = 1; i < len; i++)
@z0marlin
z0marlin / w2s4.cpp
Created January 21, 2019 17:19
WEC Codebuddy sem-4 week-2
class Solution {
public:
bool canPartition(vector<int>& nums) {
int sum = 0, n = nums.size();
for (auto a : nums){
sum += a;
}
if(sum&1)
return false;
@z0marlin
z0marlin / mountpoll.go
Created March 19, 2021 15:27
Sample go code to monitor changes to mounts on linux using epoll
package main
import (
"log"
"os"
"syscall"
)
const mpath = "/proc/mounts"
@z0marlin
z0marlin / GSOC_21_Work_Product.md
Last active August 23, 2021 15:19
GSoC 21 work product for final evaluation

GSOC 21: Work Product Submission

Org: CNCF

Project: OpenEBS: Update mount-points and capacity of Block Devices without restarting NDM

Proposal: https://bit.ly/3D1qitD

Introduction