1227. Airplane Seat Assignment Probability Medium
1/**
2 * [1227] Airplane Seat Assignment Probability
3 *
4 * n passengers board an airplane with exactly n seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of the passengers will:
5 *
6 * Take their own seat if it is still available, and
7 * Pick other seats randomly when they find their seat occupied
8 *
9 * Return the probability that the n^th person gets his own seat.
10 *
11 * Example 1:
12 *
13 * Input: n = 1
14 * Output: 1.00000
15 * Explanation: The first person can only get the first seat.
16 * Example 2:
17 *
18 * Input: n = 2
19 * Output: 0.50000
20 * Explanation: The second person has a probability of 0.5 to get the second seat (when first person gets the first seat).
21 *
22 *
23 * Constraints:
24 *
25 * 1 <= n <= 10^5
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/airplane-seat-assignment-probability/
31// discuss: https://leetcode.com/problems/airplane-seat-assignment-probability/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn nth_person_gets_nth_seat(n: i32) -> f64 {
37 0f64
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_1227() {
49 }
50}
51
Back
© 2025 bowen.ge All Rights Reserved.