File tree 4 files changed +48
-0
lines changed
solution/1200-1299/1227.Airplane Seat Assignment Probability
4 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,8 @@ f(n) = \begin{cases}
142
142
\end{cases}
143
143
$$
144
144
145
+ 时间复杂度 $O(1)$,空间复杂度 $O(1)$。
146
+
145
147
<!-- tabs:start -->
146
148
147
149
#### Python3
@@ -184,6 +186,24 @@ func nthPersonGetsNthSeat(n int) float64 {
184
186
}
185
187
```
186
188
189
+ #### TypeScript
190
+
191
+ ``` ts
192
+ function nthPersonGetsNthSeat(n : number ): number {
193
+ return n === 1 ? 1 : 0.5 ;
194
+ }
195
+ ```
196
+
197
+ #### Rust
198
+
199
+ ``` rust
200
+ impl Solution {
201
+ pub fn nth_person_gets_nth_seat (n : i32 ) -> f64 {
202
+ return if n == 1 { 1.0 } else { 0.5 };
203
+ }
204
+ }
205
+ ```
206
+
187
207
<!-- tabs: end -->
188
208
189
209
<!-- solution: end -->
Original file line number Diff line number Diff line change @@ -136,6 +136,8 @@ f(n) = \begin{cases}
136
136
\end{cases}
137
137
$$
138
138
139
+ The time complexity of this solution is $O(1)$, and the space complexity is $O(1)$.
140
+
139
141
<!-- tabs:start -->
140
142
141
143
#### Python3
@@ -178,6 +180,24 @@ func nthPersonGetsNthSeat(n int) float64 {
178
180
}
179
181
```
180
182
183
+ #### TypeScript
184
+
185
+ ``` ts
186
+ function nthPersonGetsNthSeat(n : number ): number {
187
+ return n === 1 ? 1 : 0.5 ;
188
+ }
189
+ ```
190
+
191
+ #### Rust
192
+
193
+ ``` rust
194
+ impl Solution {
195
+ pub fn nth_person_gets_nth_seat (n : i32 ) -> f64 {
196
+ return if n == 1 { 1.0 } else { 0.5 };
197
+ }
198
+ }
199
+ ```
200
+
181
201
<!-- tabs: end -->
182
202
183
203
<!-- solution: end -->
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn nth_person_gets_nth_seat ( n : i32 ) -> f64 {
3
+ return if n == 1 { 1.0 } else { 0.5 } ;
4
+ }
5
+ }
Original file line number Diff line number Diff line change
1
+ function nthPersonGetsNthSeat ( n : number ) : number {
2
+ return n === 1 ? 1 : 0.5 ;
3
+ }
You can’t perform that action at this time.
0 commit comments