0
0
DSA Pythonprogramming~10 mins

Find the Only Non Repeating Element Using XOR in DSA Python - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the result variable for XOR operation.

DSA Python
def find_non_repeating(arr):
    result = [1]
    for num in arr:
        result ^= num
    return result
Drag options to blanks, or click blank then click option'
ANone
B1
C0
Darr[0]
Attempts:
3 left
💡 Hint
Common Mistakes
Initializing result with arr[0] causes skipping the first element in XOR.
2fill in blank
medium

Complete the code to XOR each element with the result.

DSA Python
def find_non_repeating(arr):
    result = 0
    for num in arr:
        result [1]= num
    return result
Drag options to blanks, or click blank then click option'
A&
B+
C|
D^
Attempts:
3 left
💡 Hint
Common Mistakes
Using + or & instead of ^ changes the logic and output.
3fill in blank
hard

Fix the error in the function call to print the unique element.

DSA Python
arr = [2, 3, 5, 4, 5, 3, 4]
print(find_non_repeating[1]arr[2])
Drag options to blanks, or click blank then click option'
A[, ]
B(, )
C{, }
D<, >
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets or braces instead of parentheses for function calls.
4fill in blank
hard

Fill both blanks to complete the function that returns the unique element from the list.

DSA Python
def find_non_repeating(arr):
    result = [1]
    for num in arr:
        result [2]= num
    return result
Drag options to blanks, or click blank then click option'
A0
B1
C+
D^
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of ^ changes the logic.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each number to its XOR with 1 if it is greater than 2.

DSA Python
result = {num: num[1]1 for num in arr if num [2] 2}
filtered = {k: v for k, v in result.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
A^
B>
C!=
D&
Attempts:
3 left
💡 Hint
Common Mistakes
Using & instead of ^ for XOR, or == instead of != for filtering.