Review Swift codes (#1150)

* feat(swift): review for chapter_computational_complexity

* feat(swift): review for chapter_data_structure

* feat(swift): review for chapter_array_and_linkedlist

* feat(swift): review for chapter_stack_and_queue

* feat(swift): review for chapter_hashing

* feat(swift): review for chapter_tree

* feat(swift): add codes for heap article

* feat(swift): review for chapter_heap

* feat(swift): review for chapter_graph

* feat(swift): review for chapter_searching

* feat(swift): review for chapter_sorting

* feat(swift): review for chapter_divide_and_conquer

* feat(swift): review for chapter_backtracking

* feat(swift): review for chapter_dynamic_programming

* feat(swift): review for chapter_greedy

* feat(swift): review for utils

* feat(swift): update ci tool

* feat(swift): trailing closure

* feat(swift): array init

* feat(swift): map index
This commit is contained in:
nuomi1
2024-03-20 21:15:39 +08:00
committed by GitHub
parent 300a781fab
commit 7359a7cb4b
55 changed files with 293 additions and 224 deletions

View File

@@ -13,7 +13,7 @@ func backtrack(state: inout [Int], target: Int, choices: [Int], start: Int, res:
}
//
// start
for i in stride(from: start, to: choices.count, by: 1) {
for i in choices.indices.dropFirst(start) {
// target
// target
if target - choices[i] < 0 {

View File

@@ -12,7 +12,7 @@ func backtrack(state: inout [Int], target: Int, total: Int, choices: [Int], res:
return
}
//
for i in stride(from: 0, to: choices.count, by: 1) {
for i in choices.indices {
// target
if total + choices[i] > target {
continue

View File

@@ -14,7 +14,7 @@ func backtrack(state: inout [Int], target: Int, choices: [Int], start: Int, res:
//
// start
// start
for i in stride(from: start, to: choices.count, by: 1) {
for i in choices.indices.dropFirst(start) {
// target
// target
if target - choices[i] < 0 {