Advertisement
Alexxik

Untitled

Mar 21st, 2024
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.95 KB | None | 0 0
  1. // Задача с собеса про логирование действий на экране
  2.  
  3. func isNavigationSame(screensArraysOne: [String], screensArraysTwo: [String]) -> Bool {
  4.     var pointerOne = 0
  5.     var pointerTwo = 0
  6.    
  7.     while pointerOne < screensArraysOne.count
  8.             || pointerTwo < screensArraysTwo.count {
  9.        
  10.         let screenOne = screensArraysOne[pointerOne]
  11.         let screenTwo = screensArraysTwo[pointerTwo]
  12.        
  13.         if screenOne != screenTwo {
  14.              return false
  15.         }
  16.        
  17.         while pointerOne < screensArraysOne.count, screensArraysOne[pointerOne] == screenOne {
  18.             pointerOne += 1
  19.         }
  20.        
  21.         while pointerTwo < screensArraysTwo.count, screensArraysTwo[pointerTwo] == screenTwo {
  22.             pointerTwo += 1
  23.         }
  24.     }
  25.    
  26.     return true
  27. }
  28.  
  29. isNavigationSame(screensArraysOne: ["A", "A", "B", "C"], screensArraysTwo: ["A", "B", "B", "D"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement