Skip to content

Instantly share code, notes, and snippets.

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

Erhan Yaşar erhanyasar

🏠
Working from home
View GitHub Profile
/*
Given Brief
# Find a total ordered quantity of a product for every weekday
You are asked to improve the analytics of an e-commerce platform: calculating a total quantity of a given product ordered should be added.
# Task
Implement `OrdersAnalyzer.totalQuantity(orders, productId)` method which
/*
Write a Function According to Given Brief:
The MEX number of a non-negative set of numbers is the smallest non-negative number that is not present in the set.
For example, MEX([1, 3, 10]) = 0, and MEX([0, 1, 2, 8]) = 3.
Your task is to take a given array arr of length num and remove the minimum number of elements from it so that,
the MEX value of the modified array is not equal to the MEX value of the original array.
- It should return the minimum number of elements that needed to be removed from the array
@erhanyasar
erhanyasar / gist:eb7a4e7de44ef1101cd6032468c03f4e
Created July 24, 2023 14:37
A function returns depth for a given number under given conditions
/*
The depth of an integer n is defined to be how many multiples of n it is necessary to compute
before all 10 digits have appeared at least once in some multiple.
Example: let see n=42
Multiple value digits comment
42*1 42 2,4
42*2 84 8 4 existed
42*3 126 1,6 2 existed
// 1. Write a function for strings that return a string that's repeating the string
// for a given integer number for instance, given `"hello".repeatify(3)` expression
// should return "hello, hello, hello" as an output
String.prototype.repeatify = function (param) {
let result = "";
for (let i = 0; i < param; i++) result += `, ${this}`;
return result.slice(1).trim();
};
let numbersArr = [4, 6, 7, 9, 12];
function findSecondBiggestNumber(numbers) {
numbers.sort((a, b) => a - b);
return numbers[numbers.length - 2];
}
// console.log(findSecondBiggestNumber(numbersArr));
let strForReverse = "Erhan";
const dataArr = [
"B$u$i$ld",
"$t$$h$e",
"N$e$x$t",
"E$$ra",
"$$o$f$",
"S$$of$t$wa$r$e",
"De$$ve$l$op$me$n$t",
];
const solution = (numbers) => {
let maxNumber = 0;
for (let i=0; i<numbers.length; i++){
if (numbers.length < 1)
return maxNumber;
if (numbers[i] > maxNumber)
maxNumber = numbers[i];
}
return maxNumber;
@erhanyasar
erhanyasar / Converting Object to an Array
Last active March 9, 2023 14:21
Simple Quiz Solutions
const object = {
'1': 30,
'2': 58
};
function objectToArrConverter (obj) {
if (Object.entries(obj).length === 0)
return [];
else {
let arr = Object.entries(obj);
@erhanyasar
erhanyasar / findMissing
Last active March 9, 2023 14:11
Some Quiz Questions Solved
let A = [4,12,9,5,6,1],
B = [4,9,12,6];
function findMissing(A, B){
let missingElements = [];
for (var i=0; i<A.length; i++){
for (var j=0; j<B.length; j++){
if (A[i] == B[j])
break;
@erhanyasar
erhanyasar / barcodeReader.js
Last active March 9, 2023 14:00
A sample integration to use related barcode applications in order to read QR data
function tryAppStore() {
setTimeout(function() {
window.location = "https://appsto.re/tr/6XPCz.i";
}, 25);
window.location="Barcode://scan/";
}
function tryGoogleStore() {
setTimeout(function() {
window.location = "https://play.google.com/store/apps/details?id=com.google.zxing.client.android&hl=en";