Skip to content

Instantly share code, notes, and snippets.

View adist98's full-sized avatar

Aditya Soni adist98

  • Bangalore, India
View GitHub Profile
@adist98
adist98 / Code.cpp
Created January 4, 2018 21:50
Go to codes.
// Singly Linked List implementation in c++
#include <iostream>
using namespace std;
struct node
{
int data;
node *next;
/* Function to calculate x raised to the power y in O(logn)*/
int power(int x, unsigned int y)
{
int temp;
if( y == 0)
return 1;
temp = power(x, y/2);
if (y%2 == 0)
return temp*temp;
else
#include <stdio.h>
void multiply(int F[2][2], int M[2][2]); // function to multiply two 2x2 matrices
void power(int F[2][2], int n); // function to calculate the power
/* function that returns nth Fibonacci number */
int fib(int n)
{
int F[2][2] = {{1,1},{1,0}};
@adist98
adist98 / flib-matex.cpp
Created June 18, 2019 22:57
The most beautiful, clean and concise matrix exponentiation i have seen till now. SPOJ - FLIB
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
// static RangeSumQuery using segment trees //
#include<bits/stdc++.h>
using namespace std;
void ConstructTree(long long int input[], long long int segTree[],long long int low,long long int high,long long int pos){
if(low == high){
segTree[pos] = input[low];
return;
}
// coder : adist98
// dynamic RangeSumQuery using segment trees and lazy propagation//
#include<bits/stdc++.h>
using namespace std;
void updateSegTreelazy(long long int segTree[], long long int lazy[], long long int startRange, long long int endRange, long long int delta, long long int low, long long int high, long long int pos){
if(low > high){
return;
// DigitDP variation for calculating the sum of digits - CPCRC1C on SPOJ
// Code inspired by GeeksforGeeks - coded by adist98
// Given two integers a and b. The task is to print
// sum of all the digits appearing in the
// integers between a and b
#include "bits/stdc++.h"
using namespace std;
// Memoization for the state results
long long int dp[20][180][2];
// coder : adist98
// Given two long long integers a and b. The task is to prlong long int
// sum of all the digits appearing in the
// long long integers between a and b
#include "bits/stdc++.h"
using namespace std;
// Memoization for the state results
long long int dp[52][50][50][50][2];
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int mx=1e4+1;
vector<int>v[mx];
int cont=0;
@adist98
adist98 / GoogleFormsApi&ClickupApi.js
Created April 14, 2021 18:40
This code was written to create clickUp tasks automatically based off of entries in google form. The idea is to manage stuff in a structural manner and keep a record accordingly.
// coded and assembled by adist98
const fs = require('fs');
const readline = require('readline');
const {google} = require('googleapis');
const { fileURLToPath } = require('url');
// If modifying these scopes, delete token.json.
const SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly'];
// The file token.json stores the user's access and refresh tokens, and is
// created automatically when the authorization flow completes for the first