We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6172cd8 commit d6fc8f1Copy full SHA for d6fc8f1
leetcode.com/swift/DS_ALGO_PRAC.playground/Contents.swift
@@ -1,2 +1,22 @@
1
import Foundation
2
-
+class Solution {
3
+ func minimumEffortPath(_ heights: [[Int]]) -> Int {
4
+ guard !heights.isEmpty, !heights[0].isEmpty else {
5
+ return 0
6
+ }
7
+ var heights = heights
8
+ var minEffort = heights[0][0]
9
+ var queue = Array([0,0])
10
+ while !queue.isEmpty {
11
+ var currentCell = queue.removeFirst()
12
+ var (currentX, currentY) = (currentCell[0], currentCell[1])
13
+ var currentMinEffort = heights[currentX][currentY]
14
+ var currentLevelSize = queue.count
15
+
16
+ for _ in 0..<currentLevelSize {
17
18
19
+ minEffort = max(minEffort, currentMinEffort)
20
21
22
+}
0 commit comments