Commit 970ee90f by ASAHI OCEAN Committed by GitHub

### Merge pull request #213 from asahiocean/develop

`Update Contents.swift`
parents 290804a1 f1bb3d78
 import Foundation // 1488. Avoid Flood in The City // https://leetcode.com/problems/avoid-flood-in-the-city/ // Discuss: https://vk.cc/c4akh5 class Solution { func avoidFlood(_ rains: [Int]) -> [Int] { var result = [Int](repeating: -1, count: rains.count) var map = [Int:[Int]]() var dd = [Int]() var map = [Int:[Int]](), dd = [Int]() for i in 0.. map[r]![1] { result[dd[j]] = r dd.remove(at: j) map[r]![1] = i break } for j in 0.. map[r]![1] { result[dd[j]] = r dd.remove(at: j) map[r]![1] = i break } } } } dd.forEach({ result[\$0] = 1 }) dd.forEach{ result[\$0] = 1 } return result } } ... ... @@ -42,19 +41,19 @@ import XCTest class Tests: XCTestCase { private let s = Solution() func testExample1() { func test0() { XCTAssertEqual(s.avoidFlood([1,2,3,4]), [-1,-1,-1,-1]) } func testExample2() { func test1() { XCTAssertEqual(s.avoidFlood([1,2,0,0,2,1]), [-1,-1,2,1,-1,-1]) } func testExample3() { func test2() { XCTAssertEqual(s.avoidFlood([1,2,0,1,2]), []) } func testExample4() { func test3() { XCTAssertEqual(s.avoidFlood([69,0,0,0,69]), [-1,69,1,1,-1]) } func testExample5() { func test4() { XCTAssertEqual(s.avoidFlood([10,20,20]), []) } } ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!