leetcode

Leetcode submissions
git clone git://git.laack.co/leetcode.git
Log | Files | Refs | README

airplane-seat-assignment-probability.dart (423B)


      1 //Given n number of people getting on a plane with n seats what are the odds
      2 //that the nth passenger gets their original seat assuming the first person sits in a random
      3 //seat.
      4 //Time complexity is O(1). 
      5 //This question is bad.
      6 //Time: 272ms Beats: 100%
      7 //Memory: 140.8MB Beats: 100%
      8 
      9 class Solution {
     10   double nthPersonGetsNthSeat(int n) {
     11     if(n == 1){
     12       return 1;
     13     }
     14     else{
     15       return (.5); 
     16     }
     17   }
     18 }