Skip to content

Instantly share code, notes, and snippets.

@Sara3
Sara3 / interviewQuestion
Last active July 24, 2021 19:14
question
Fetcher interface:
fetchAnimals(prefix: string, callback: function): void
fetchArticles(prefix: string, callback: function): void
fetchFruits(prefix: string, callback: function): void
Note: there are many more fetchers
Callback interface:
callback(results: string[]): void
*/
fetchAnimals('g', (results) => console.log(results));
/*
* HW 2 - Recursion
*/
'use strict';
/*
* Problem: Powerset
*
* Prompt: Given a set S, return the powerset P(S), which is
Item Price (AF) Price ($) units total
Flour 2.140 30.01 2 60.02
Macaroni 450 6.31 1 6.31
Oil 390 5.47 2 10.94
Rice 2.250 31.56 1 31.56
Cash to buy Eidy clothes 4.000 56.10 1 56.10
Total 164.93
USERS SAML JIT SCIM
Create YES YES
Update YES YES
Read NO YES
Deactivate NO YES
Password Sync NO YES
//array of two objects [{name, time}, {name, time}, {name, time}]
//# pageViews=> how many times a page is viewed
//# of users => have many different users have used the web
//# sessions => how many have viewed the page with half an hour time break in between
function main(){
//example array
var pageView = [{'name':'Sara', 'time': 1}, {'name': 'John', 'time':2},{'name':'Sara', 'time': 1}, {'name': 'Hadis', 'time':2},{'name':'Sara', 'time': 1}, {'name': 'Hadis', 'time':33}]
// var pageView = [{name: 'sara', 'time': 1}]
//array of two objects [{name, time}, {name, time}, {name, time}]
//# pageViews=> how many times a page is viewed
//# of users => have many different users have used the web
//# sessions => how many have viewed the page with half an hour time break in between
function main(){
//example array
//var pageView = [{'name':'Sara', 'time': 1}, {'name': 'John', 'time':2},{'name':'Sara', 'time': 1}, {'name': 'Hadis', 'time':2},{'name':'Sara', 'time': 1}, {'name': 'Hadis', 'time':33}]
var pageView = [{name: 'sara', 'time': 1}]
/*
Install mysql -> https://dev.mysql.com/doc/mysql-osx-excerpt/5.5/en/osx-installation-pkg.html
run the server
log in with 'root' user
log in with mysql -u root -p;
create a super user like (https://dev.mysql.com/doc/refman/5.5/en/adding-users.html)
in another termilal log in with the user info. 'sara'
mysql -u sara -p;
var messageBus = {
subscrib: function(str, callback) {
// make a key in the parent object
if (!this[str]) {
this[str] = [];
this[str].push(callback)
} else {
this[str].push(callback)
}
/**
* @param {number[]} nums
* @return {number[]}
*/
var productExceptSelf = function(nums) {
//i: array
let output = []
//need to handle division by 0 [1, 0] => [0, 1]
// need to handle division by -number [9,0,-2] => [0,-18,0]
//
class CashAmount{
constructor(amount) {
this.amount = amount;
this.pennies = this.amount * 100;
}
addDoubleAmount (newAdd) {
this.amount += newAdd;
this.pennies += newAdd*100;
}