leetcode

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit a362567820f2fecc1f5bded96dbff6fcfdac8461
parent d9f1632a2059b11d4ccd2ca4e846cdf20a8f14ae
Author: AndrewLockVI <andrewlaack1@gmail.com>
Date:   Sun, 21 May 2023 12:22:00 -0500

Completed airplane seat assignment problem using dart

Diffstat:
Aairplane-seat-assignment-probability/airplane-seat-assignment-probability.dart | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/airplane-seat-assignment-probability/airplane-seat-assignment-probability.dart b/airplane-seat-assignment-probability/airplane-seat-assignment-probability.dart @@ -0,0 +1,18 @@ +//Given n number of people getting on a plane with n seats what are the odds +//that the nth passenger gets their original seat assuming the first person sits in a random +//seat. +//Time complexity is O(1). +//This question is bad. +//Time: 272ms Beats: 100% +//Memory: 140.8MB Beats: 100% + +class Solution { + double nthPersonGetsNthSeat(int n) { + if(n == 1){ + return 1; + } + else{ + return (.5); + } + } +}