Skip to content

Instantly share code, notes, and snippets.

View rishabhjain1997's full-sized avatar
🏠
Working from home

Rishabh Jain rishabhjain1997

🏠
Working from home
View GitHub Profile
import random
answers = [
"It is certain",
"Without a doubt",
"You may rely on it",
"Yes definitely",
"It is decidedly so",
"As I see it, yes",
"Most likely",
import './App.css';
import React from 'react';
const ProgressBar = (props) => {
const { completed } = props;
const containerStyles = {
height: 20,
width: '100%',
backgroundColor: "#e8ebee",
borderRadius: 5,
from collections import deque
def queue(nums):
hashmap = dict()
q = deque((range(len(nums))))
print(q)
result = [-1] * len(nums)
while q:
print(q)
#print(hashmap)
index = q.popleft()
class Solution:
def maximalSquare(self, matrix: List[List[str]]) -> int:
dp = [[0 for _ in range(len(matrix[0])+1)] for _ in range(len(matrix)+1)]
max_square = 0
for i in range(1, len(matrix) + 1):
for j in range(1, len(matrix[0])+1):
if matrix[i-1][j-1] == '1':
dp[i][j] = 1 + min(dp[i-1][j-1],dp[i][j-1],dp[i-1][j])
max_square = max(max_square, dp[i][j])
return max_square
def getRatio(start, end, data):
from collections import deque
adjacency = dict()
for node in data:
if node[0] in adjacency:
adjacency[node[0]].append([node[1], float(node[2])])
else:
adjacency[node[0]] = [[node[1], float(node[2])]]
max_val = float('-inf')
q = deque([(start, 1.0)])
def getRatio(start, end, data):
from collections import deque
adjacency = dict()
for node in data:
if node[0] in adjacency:
adjacency[node[0]].append([node[1], node[2]])
else:
adjacency[node[0]] = [[node[1], node[2]]]
max_val = float('-inf')
q = deque([(start, 1.0)])
import React from 'react';
const ProgressBar = (props) => {
const { completed } = props;
const containerStyles = {
height: 20,
width: '100%',
backgroundColor: "#e8ebee",
borderRadius: 5,
margin: 50
class Solution:
def solution(self, S):
curr = set()
count = 1
for letter in list(S):
if letter in curr:
curr = set()
count += 1
curr.add(letter)
return count
class Solution:
def sumZero(self, n: int) -> List[int]:
if n == 1:
return [0]
res = [0 for x in range(n)] # fill array with 0
c = 1
# Fill array with disctinc numbers in the following pattern . [-1,-2,0, 2,1]
left, right = 0, len(res)-1
while left < right:
res[left] = c * -1
from collections import Counter
def form_palindrome(S):
if not S:
return 0
c = dict(Counter(S))
odd_counter = 0
for k,v in c.items():
if v %2 != 0:
odd_counter+=1
if odd_counter ==0: