Skip to content

Commit ea555cc

Browse files
author
Thukor
committed
Fixed a logic bug
1 parent 8c11c04 commit ea555cc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Trie/trie.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
public struct Queue<T> {
55
private var array = [T?]()
66
private var head = 0
7-
7+
88
public var isEmpty: Bool {
99
return count == 0
1010
}
1111

1212
public var count: Int {
1313
return array.count - head
1414
}
15-
15+
1616
public mutating func enqueue(element: T) {
1717
array.append(element)
1818
}
19-
19+
2020
public mutating func dequeue() -> T? {
2121
guard head < array.count, let element = array[head] else { return nil }
2222

@@ -28,7 +28,7 @@ public struct Queue<T> {
2828
array.removeFirst(head)
2929
head = 0
3030
}
31-
31+
3232
return element
3333
}
3434
}
@@ -388,11 +388,11 @@ public class Trie {
388388
Functionality: attempts to insert all words from input array. returns a tuple containing the input array and true if some of the words were succesffuly added, false if none were added
389389
*/
390390

391-
func insertWords(wordList: [String]) -> (wordList: [String], bool: inserted){
391+
func insertWords(wordList: [String]) -> (wordList: [String], inserted: Bool){
392392

393-
var successful: Bool = false
393+
var succesful: Bool = false
394394
for word in wordList {
395-
succesful |= self.insert(word).inserted
395+
succesful = self.insert(word).inserted || succesful
396396
}
397397

398398
return(wordList, succesful)

0 commit comments

Comments
 (0)