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
#include<iostream> | |
#include<string> | |
using namespace std; | |
int *pre_kmp(string pattern) | |
{ | |
int size = pattern.size(); | |
int *pie=new int [size]; | |
pie[0] = 0; |
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
#Python | |
def fibonacci(n): | |
print n | |
if n == 0 or n == 1: | |
return 1 | |
else: | |
return fibonacci(n-1) + fibonacci(n-2) | |
if __name__ == "__main__": | |
from sys import argv |
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
def gcd(a,b): | |
while(b!=0): | |
a,b=b,a%b | |
return a | |
def lcm(*args): | |
from functools import reduce | |
import math | |
return reduce(lambda a,b:(a*b)/math.gcd(int(a),int(b)), args) |
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
arr = [1, 2, 3, 4] | |
from collections import deque | |
qu = deque([[a] for a in range(len(arr))]) | |
while qu: | |
q = qu.popleft() | |
print([arr[i] for i in q]) | |
for j in range(q[-1]+1, len(arr)): | |
qu.append(q + [j]) |
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
// paste this script in the js console of https://www.linkedin.com/mynetwork/invitation-manager/ page and enjoy. | |
const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); | |
async function acceptAll () { | |
while(true) { | |
const items = document.querySelectorAll('button.artdeco-button--secondary'); | |
if (items.length === 0) break; | |
for (var i=0 ; i<items.length; i++) { | |
const item = items[i]; | |
console.log(item); |