Solving the easiest “Medium” difficulty algorithm on leet code

  • Take their own seat if it is still available,
  • Pick other seats randomly when they find their seat occupied
var nthPersonGetsNthSeat = function(n) {
n / (n * n)
};
var nthPersonGetsNthSeat = function(n) {
if (n == 1){
return 1
}else{
return .5
}
};

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How do I cool pods with KEDA / How to write a new scaler

How to generate big prime numbers — Miller-Rabin

Codemotion in Amsterdam, Devoxx in London

Let’s Integrate SonarQube with BitBucket to import Bitbucket Cloud Repositories

Kubernetes Storage By Example: Part 1

2 ways to auto-generate documentation for Laravel APIs 📄⚙️

Introduction to Airflow in Python

CS373 Fall 2021: Ian Winson

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tim Rinkerman

Tim Rinkerman

More from Medium

My Journey: Computer-Based Testing (CBT) System

Homework — Soft Skill II

2021 Year-In-Review

This is Journals. This is the Genesis, but it’s only the beginning.