Skip to content

Instantly share code, notes, and snippets.

View arpi-r's full-sized avatar

Arpitha Raghunandan arpi-r

View GitHub Profile
@arpi-r
arpi-r / QRAlgorithm.py
Created October 18, 2019 04:22
Contains QR algorithm for finding PCA
# -*- coding: utf-8 -*-
"""QRAlgorithm.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1kOXabcj86XKDY8SeeFA-prZ4w16r3CmX
Import Libraries
"""
import heapq
class Solution:
# @param A : integer
# @param B : integer
# @param C : integer
# @param D : integer
# @return a list of integers
def solve(self, A, B, C, D):
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param A : root node of tree
# @return the root node in the tree
import hashlib, json
def hash_blocks(blocks):
prev_hash = None
hashes=[]
for block in blocks:
block['prev_hash'] = prev_hash
block_serialized = json.dumps(block, sort_keys=True).encode('utf-8')
block_hash = hashlib.sha256(block_serialized).hexdigest()
hashes.append(block_hash)
@arpi-r
arpi-r / MaxRectangleInBinaryMatrix.py
Created January 21, 2019 17:04
codebuddy week10
class Solution:
# @param A : list of list of integers
# @return an integer
def histarea(self,h):
s = list()
maxarea = 0
i= 0
area = 0
while i < len(h):
@arpi-r
arpi-r / ValidSudoku.py
Created January 9, 2019 18:09
codebuddy week9
class Solution:
# @param A : tuple of strings
# @return an integer
def isValidSudoku(self, A):
for i in range(9):
ch=[0]*9
for j in range(9):
if(A[i][j]!='.'):
if(ch[ord(A[i][j])-49]==1):
@arpi-r
arpi-r / MinimumSizeSubarraySum.cpp
Created January 9, 2019 14:59
WebClub codebuddy
class Solution {
public:
int minSubArrayLen(int s, vector<int>& nums) {
int min=nums.size()+1;
int i=0,j=0;
int sum=0;
for(i=0;i<nums.size();i++){
if(nums[i]>=s){
min=1;
@arpi-r
arpi-r / IdenticalBinaryTrees.py
Created November 6, 2018 14:55
codebuddy week8
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param A : root node of tree
# @param B : root node of tree
@arpi-r
arpi-r / LevelOrder.py
Created October 28, 2018 14:26
codebuddy week7
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param A : root node of tree
# @return a list of list of integers
@arpi-r
arpi-r / SingleNumberII.cpp
Created October 22, 2018 14:32
WebClub codebuddy week3
int Solution::singleNumber(const vector<int> &A) {
vector<int> n(32,0);
int t = 1;
for(int i = 1; i < 32 ; i++){
int one = 0;
if( i==1 ){
t = 1;
}
else{
t = t<<1;