Skip to content

Commit ef3209d

Browse files
committed
feat: add rust solution to lc problem: No.1791
No.1791.Find Center of Star Graph
1 parent 13f21fa commit ef3209d

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

solution/1700-1799/1791.Find Center of Star Graph/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ func findCenter(edges [][]int) int {
108108
}
109109
```
110110

111+
### **Rust**
112+
113+
```rust
114+
impl Solution {
115+
pub fn find_center(edges: Vec<Vec<i32>>) -> i32 {
116+
if edges[0][0] == edges[1][0] || edges[0][0] == edges[1][1] {
117+
return edges[0][0];
118+
}
119+
edges[0][1]
120+
}
121+
}
122+
```
123+
111124
### **...**
112125

113126
```

solution/1700-1799/1791.Find Center of Star Graph/README_EN.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@ func findCenter(edges [][]int) int {
109109
}
110110
```
111111

112+
### **Rust**
113+
114+
```rust
115+
impl Solution {
116+
pub fn find_center(edges: Vec<Vec<i32>>) -> i32 {
117+
if edges[0][0] == edges[1][0] || edges[0][0] == edges[1][1] {
118+
return edges[0][0];
119+
}
120+
edges[0][1]
121+
}
122+
}
123+
```
124+
112125
### **...**
113126

114127
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
impl Solution {
2+
pub fn find_center(edges: Vec<Vec<i32>>) -> i32 {
3+
if edges[0][0] == edges[1][0] || edges[0][0] == edges[1][1] {
4+
return edges[0][0];
5+
}
6+
edges[0][1]
7+
}
8+
}

0 commit comments

Comments
 (0)