LeetCode Username
ankur1082
Problem Number, Title, and Link
https://leetcode.com/problems/longest-subsequence-with-non-zero-bitwise-xor/
Bug Category
Missing test case (Incorrect/Inefficient Code getting accepted because of missing test cases)
Bug Description
I found a bug in a contest question when I submit my code it passed all the test cases but when I write
My custom Testcase - [0,1,2,1,2] it give wrong output acc to my code even after passing all leetcode testcases
Output - 0(according to my code)
Expected - 4
Language Used for Code
Java
Code used for Submit/Run operation
class Solution {
public int longestSubsequence(int[] nums) {
int xor = 0;
for(int num : nums) {
xor ^= num;
}
if(xor != 0) return nums.length;
if((xor ^ nums[0]) != 0) return nums.length - 1;
return 0;
}
}
Expected behavior
My custom Testcase - [0,1,2,1,2]
Output - 0
Expected - 4
Screenshots
Additional context
No response
LeetCode Username
ankur1082
Problem Number, Title, and Link
https://leetcode.com/problems/longest-subsequence-with-non-zero-bitwise-xor/
Bug Category
Missing test case (Incorrect/Inefficient Code getting accepted because of missing test cases)
Bug Description
I found a bug in a contest question when I submit my code it passed all the test cases but when I write
My custom Testcase - [0,1,2,1,2] it give wrong output acc to my code even after passing all leetcode testcases
Output - 0(according to my code)
Expected - 4
Language Used for Code
Java
Code used for Submit/Run operation
class Solution { public int longestSubsequence(int[] nums) { int xor = 0; for(int num : nums) { xor ^= num; } if(xor != 0) return nums.length; if((xor ^ nums[0]) != 0) return nums.length - 1; return 0; } }Expected behavior
My custom Testcase - [0,1,2,1,2]
Output - 0
Expected - 4
Screenshots
Additional context
No response