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
# python3 program for spiral matrix | |
def spiralOrder(matrix): | |
ans = [] | |
if (len(matrix) == 0): | |
return ans | |
m = len(matrix) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/python | |
def heapify(arr, n, i): | |
largest = i # Initialize largest as root | |
l = 2 * i + 1 # left = 2*i + 1 | |
r = 2 * i + 2 # right = 2*i + 2 | |
# See if left child of root exists and is | |
# greater than root |
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 maxProfit(arr): | |
max_profit = 0 | |
diff = 0 | |
mlen = len(arr) | |
for i in range(mlen): | |
for j in range( i+1 ,mlen): | |
if arr[i] < arr[j]: | |
diff = arr[j] - arr[i] | |
if max_profit < diff: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 merge(arr, start , end): | |
if (start >= end): | |
return | |
mid = (end+start)//2 | |
merge(arr, start, mid) | |
merge(arr, mid+1, end) | |
left = start | |
right = mid+1 | |
aux = [] |
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 numpy as np | |
import tensorflow as tf | |
import tensorflow_hub as hub | |
import tensorflow_text as tf_text | |
import tensorflow_datasets as tfds | |
from official.nlp.data import classifier_data_lib | |
from official.nlp.bert import tokenization | |
from official.nlp import optimization | |
import matplotlib | |
matplotlib.use('module://matplotlib-backend-kitty') |
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
from transformers import BertForQuestionAnswering, AutoTokenizer | |
modelname = 'deepset/bert-base-cased-squad2' | |
model = BertForQuestionAnswering.from_pretrained(modelname) | |
tokenizer = AutoTokenizer.from_pretrained(modelname) | |
from transformers import pipeline | |
nlp = pipeline('question-answering', model=model, tokenizer=tokenizer) |
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=[5,4,8, 10,-4] | |
k=6 | |
def check_if_sum_possible(arr, k): | |
slate = [] | |
index = 0 | |
arrlen = 0 | |
if arr: | |
arrlen = len(arr) |
NewerOlder