알고리즘문풀 with SWIFT/LeetCode

swift ) Leetcode - 771. Jewels and Stones

유사앱등이 2022. 11. 27. 16:09

 

 

 771. Jewels and Stones 

// 771. Jewels and Stones -1 (for *2)

func numJewelsInStones(_ jewels: String, _ stones: String) -> Int {
	var result = 0

	for i in stones {
		for j in jewels {
			if String(j) == String(i) {
				result += 1
			}
		}
	}
	return result
}

 

for loop 두 개 중첩...