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
# -*- coding: utf-8 -*- | |
"""QRAlgorithm.ipynb | |
Automatically generated by Colaboratory. | |
Original file is located at | |
https://colab.research.google.com/drive/1kOXabcj86XKDY8SeeFA-prZ4w16r3CmX | |
Import Libraries | |
""" |
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
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): | |
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
# 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 |
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
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) |
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
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): |
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
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): |
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
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; |
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
# 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 |
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
# 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 |
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
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; |
NewerOlder