Practice Bulls and Cows
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given the digit strings secret and guess, return a hint in the form "xAyB". A bull is a guessed digit that matches the secret at the same position. After excluding bulls, a cow is a remaining guessed digit that can be matched to the same digit at a different position in the secret. Count each occurrence at most once, including when digits repeat. Let x be the number of bulls and y the number of cows.
Source: Bulls and Cows on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
secret = "1807", guess = "7810"
"1A3B"
# Example 2
secret = "1123", guess = "0111"
"1A1B"
Constraints
Related LeetCode Problems
Practice more problems similar to Bulls and Cows.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.