From b6f21c305e253ee2fedc9a59bf67eed70bbbc541 Mon Sep 17 00:00:00 2001 From: zhaocchen Date: Thu, 22 Jul 2021 16:45:43 +0800 Subject: [PATCH] feat: add typescript solution to lc problem: No.1791.Find Center of Star Graph --- .../1791.Find Center of Star Graph/README.md | 12 ++++++++++++ .../1791.Find Center of Star Graph/README_EN.md | 12 ++++++++++++ .../1791.Find Center of Star Graph/Solution.ts | 7 +++++++ 3 files changed, 31 insertions(+) create mode 100644 solution/1700-1799/1791.Find Center of Star Graph/Solution.ts diff --git a/solution/1700-1799/1791.Find Center of Star Graph/README.md b/solution/1700-1799/1791.Find Center of Star Graph/README.md index ab9781f09e438..2e80bf2d8c738 100644 --- a/solution/1700-1799/1791.Find Center of Star Graph/README.md +++ b/solution/1700-1799/1791.Find Center of Star Graph/README.md @@ -65,6 +65,18 @@ class Solution: ``` +### **TypeScript** + +```ts +function findCenter(edges: number[][]): number { + for (let num of edges[0]) { + if (edges[1].includes(num)) { + return num; + } + } +}; +``` + ### **...** ``` diff --git a/solution/1700-1799/1791.Find Center of Star Graph/README_EN.md b/solution/1700-1799/1791.Find Center of Star Graph/README_EN.md index dc7eb5d8b4230..daa09f21979f0 100644 --- a/solution/1700-1799/1791.Find Center of Star Graph/README_EN.md +++ b/solution/1700-1799/1791.Find Center of Star Graph/README_EN.md @@ -77,6 +77,18 @@ class Solution: ``` +### **TypeScript** + +```ts +function findCenter(edges: number[][]): number { + for (let num of edges[0]) { + if (edges[1].includes(num)) { + return num; + } + } +}; +``` + ### **...** ``` diff --git a/solution/1700-1799/1791.Find Center of Star Graph/Solution.ts b/solution/1700-1799/1791.Find Center of Star Graph/Solution.ts new file mode 100644 index 0000000000000..78a035000eb1d --- /dev/null +++ b/solution/1700-1799/1791.Find Center of Star Graph/Solution.ts @@ -0,0 +1,7 @@ +function findCenter(edges: number[][]): number { + for (let num of edges[0]) { + if (edges[1].includes(num)) { + return num; + } + } +}; \ No newline at end of file