filmov
tv
1. Cookie Problem | JavaScript | Coding Interview | Challenge

Показать описание
#Challenge
You are given an `array` representing how many cookies each person in a group has. You don't want anyone to start arguing over who has more cookies. You want each person to have the same amount of cookies, but you can't take away any cookies from anyone, instead you need to give each person extra cookies until they all have the same amount.
You have to find out how many cookies each person has, and give them each additional cookies until they have as many cookies as the person with the most cookies.
Return the total amount of additional cookies you needed give out.
Example:
cookieProblem ( [ 4, 5, 6 ] ) // it should returns 3
- 6 is the most highest amount of cookies.
- So each person should have 6 cookies
- Person 1 has 4 cookies, so he needs 6-4 i.e. 2 additional cookies
- Person 2 has 5 cookies, so he needs 6-5 i.e. 1 additional cookie
- Therefore, 2 + 1 = 3 total additional cookies should be given out
#javascript #interview #coding #Interviewquestion #codingchallenge #cookieproblem #askFaran
You are given an `array` representing how many cookies each person in a group has. You don't want anyone to start arguing over who has more cookies. You want each person to have the same amount of cookies, but you can't take away any cookies from anyone, instead you need to give each person extra cookies until they all have the same amount.
You have to find out how many cookies each person has, and give them each additional cookies until they have as many cookies as the person with the most cookies.
Return the total amount of additional cookies you needed give out.
Example:
cookieProblem ( [ 4, 5, 6 ] ) // it should returns 3
- 6 is the most highest amount of cookies.
- So each person should have 6 cookies
- Person 1 has 4 cookies, so he needs 6-4 i.e. 2 additional cookies
- Person 2 has 5 cookies, so he needs 6-5 i.e. 1 additional cookie
- Therefore, 2 + 1 = 3 total additional cookies should be given out
#javascript #interview #coding #Interviewquestion #codingchallenge #cookieproblem #askFaran
1. Cookie Problem | JavaScript | Coding Interview | Challenge
JavaScript Tutorial #11 - Cookies & Local Storage
What Happens When You Click 'Accept All?'
Storing Objects with Local Storage in JavaScript
Time… a programmer's worst enemy // The Code Report
Difference between cookies, session and tokens
Das Problem mit JavaScript Factory Functions
try, catch, finally, throw - error handling in JavaScript
JavaScript page performance problems
javascript css ~ find error | html #coding #app #javascript
How to Fix a Javascript Error in Windows 10
Hacker101 - JavaScript for Hackers (Created by @STOKfredrik)
Always Check for the Hidden API when Web Scraping
Authentication on the Web (Sessions, Cookies, JWT, localStorage, and more)
JAVASCRIPT BEGINNER EXERCISES - 5 PROBLEMS *WITH SOLUTIONS* - PART 1
Best vscode error extension #shorts #vscode #programming #javascript
How Easy Is It For Hackers To Brute Force Login Pages?!
Understanding Authentication in Node.js - Sessions and Cookies - Web Development Concepts Explained
Javascript Practice Problems for Complete Beginners: Filtering an Array
#10 Servlet and JSP Tutorial | HttpSession | Cookie
How Hackers Login To Any Websites Without Password?!
Integer Programming in Javascript Tutorial: How to Solve Integer Programming Problems
JavaScript Tutorial for Beginners: Learn JavaScript in 1 Hour
What the heck is the event loop anyway? | Philip Roberts | JSConf EU
Комментарии