if position not visited add to queue and mark visited
q . Enqueue ( new pair ( s + d1 , stp + 1 ) ) ; visited . Add ( s + d1 ) ; } if ( ! visited . Contains ( s + d2 ) ) { q . Enqueue ( new pair ( s + d2 , stp + 1 ) ) ; visited . Add ( s + d2 ) ; } if ( ! visited . Contains ( s - d1 ) ) { q . Enqueue ( new pair ( s - d1 , stp + 1 ) ) ; visited . Add ( s - d1 ) ; } if ( ! visited . Contains ( s - d2 ) ) { q . Enqueue ( new pair ( s - d2 , stp + 1 ) ) ; visited . Add ( s - d2 ) ; } } return int . MinValue ; }