Skip to content

Commit 6765e9b

Browse files
authored
feat: add solutions to lc problem: No.1227 (doocs#3600)
No.1227.Airplane Seat Assignment Probability
1 parent bd3ef8e commit 6765e9b

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

solution/1200-1299/1227.Airplane Seat Assignment Probability/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ f(n) = \begin{cases}
142142
\end{cases}
143143
$$
144144

145+
时间复杂度 $O(1)$,空间复杂度 $O(1)$。
146+
145147
<!-- tabs:start -->
146148

147149
#### Python3
@@ -184,6 +186,24 @@ func nthPersonGetsNthSeat(n int) float64 {
184186
}
185187
```
186188

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+
187207
<!-- tabs:end -->
188208

189209
<!-- solution:end -->

solution/1200-1299/1227.Airplane Seat Assignment Probability/README_EN.md

+20
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ f(n) = \begin{cases}
136136
\end{cases}
137137
$$
138138

139+
The time complexity of this solution is $O(1)$, and the space complexity is $O(1)$.
140+
139141
<!-- tabs:start -->
140142

141143
#### Python3
@@ -178,6 +180,24 @@ func nthPersonGetsNthSeat(n int) float64 {
178180
}
179181
```
180182

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+
181201
<!-- tabs:end -->
182202

183203
<!-- solution:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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 numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function nthPersonGetsNthSeat(n: number): number {
2+
return n === 1 ? 1 : 0.5;
3+
}

0 commit comments

Comments
 (0)