Created
November 18, 2024 12:42
-
-
Save natintosh/0ea6e85e252aa806d2a0656027c8afaa to your computer and use it in GitHub Desktop.
Missing Number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
Solution solution = Solution(); | |
// Test Case 1 | |
List<int> nums1 = [3, 0, 1]; | |
print('Test Case 1:'); | |
print('Input: $nums1'); | |
print('Expected Output: 2'); | |
print('Actual Output: ${solution.missingNumber(nums1)}'); | |
print(''); | |
// Test Case 2 | |
List<int> nums2 = [0, 1]; | |
print('Test Case 2:'); | |
print('Input: $nums2'); | |
print('Expected Output: 2'); | |
print('Actual Output: ${solution.missingNumber(nums2)}'); | |
print(''); | |
// Test Case 3 | |
List<int> nums3 = [9, 6, 4, 2, 3, 5, 7, 0, 1]; | |
print('Test Case 3:'); | |
print('Input: $nums3'); | |
print('Expected Output: 8'); | |
print('Actual Output: ${solution.missingNumber(nums3)}'); | |
print(''); | |
// Additional Test Cases | |
// Edge case with single element | |
List<int> nums4 = [0]; | |
print('Test Case 4 (Single element):'); | |
print('Input: $nums4'); | |
print('Expected Output: 1'); | |
print('Actual Output: ${solution.missingNumber(nums4)}'); | |
print(''); | |
// Edge case with missing 0 | |
List<int> nums5 = [1, 2]; | |
print('Test Case 5 (Missing zero):'); | |
print('Input: $nums5'); | |
print('Expected Output: 0'); | |
print('Actual Output: ${solution.missingNumber(nums5)}'); | |
} | |
class Solution { | |
int missingNumber(List<int> nums) { | |
// TODO: Implement your solution here | |
return -1; // Placeholder return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment