Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func getPath(_ n : Int) -> Set<String>{
- var res = Set<String>()
- getPathDFS(n , n , "", &res)
- return res
- }
- func getPathDFS(_ n : Int, _ m : Int, _ curr: String, _ res: inout Set<String>){
- if n == 0 && m == 0{
- res.insert(curr)
- return
- }
- if n > 0 {
- getPathDFS( n - 1, m, curr + "d", &res)
- }
- if m > 0 {
- getPathDFS( n , m - 1, curr + "r", &res)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement