This file contains hidden or 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
const mongodb = require("mongodb") | |
const MongoClient = mongodb.MongoClient | |
const connectionURL = "mongodb://127.0.0.1:27017" // Change the url in production | |
const databaseName = "task-manager" // Change the database name | |
MongoClient.connect(connectionURL, { useNewUrlParser: true, useUnifiedTopology: true }, (error, client) => { | |
if (error) { | |
return console.log("Some error occurred") | |
} |
This file contains hidden or 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
const addFunction = (a, b, callback) => { | |
setTimeout(() => { | |
const sum = a+b | |
callback(sum) | |
},1000) | |
} | |
addFunction(1, 2, (sum) => { | |
console.log(sum) | |
}) |
This file contains hidden or 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 queue | |
class Node: | |
def __init__(self): | |
self.data=None | |
self.neighbors=[] | |
class Graph: | |
def __init__(self): | |
self.root=None |
This file contains hidden or 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 queue | |
class Node: | |
def __init__(self): | |
self.data=None | |
self.neighbors=[] | |
class Graph: | |
def __init__(self): | |
self.root=None |
This file contains hidden or 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 Node: | |
def __init__(self): | |
self.data=None | |
self.left=None | |
self.right=None | |
class LL: | |
def __init__(self): | |
self.root=None | |
self.leaf=0 |
This file contains hidden or 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 binarySearch(arr, key, low, high): | |
if low>high: | |
return False | |
else: | |
mid = (low+high)/2 | |
if arr[mid]==key: | |
return True | |
elif key<arr[mid]: | |
return binarySearch(arr,key,low,mid-1) | |
else: |
This file contains hidden or 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 binarySearch(arr,key): | |
low,high=0,len(arr)-1 | |
while low<=high: | |
mid = (high+low)/2 | |
if arr[mid]==key: | |
return mid+1 | |
if key<arr[mid]: high=mid-1 | |
else: low=mid+1 | |
if low>high: return False |
This file contains hidden or 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 random import randint | |
class Account: | |
def __init__(self): | |
self.accounts = {} | |
self.name = None | |
self.initialDeposit = None | |
def createAccount(self, name, initialDeposit): |
This file contains hidden or 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 Library: | |
def __init__(self, listOfBooks): | |
self.books = listOfBooks | |
def showAllBooks(self): | |
print("\n") | |
for book in self.books: | |
print(book) | |
print("\n") |
This file contains hidden or 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 React, {useState} from 'react'; | |
const App = props => { | |
const [pstate, sstate] = useState({ | |
name: "Manoj", | |
country: "India" | |
}) | |
const switchNameHandler = () => { |