/**
* Problem: LeetCode 3513 - Number of Unique XOR Triplets I
* Difficulty: Medium
* Language: Java
* Author: CodeByTushu
*/
class Solution {
public int uniqueXorTriplets(int[] nums) {
int n = nums.length;
if (n == 1) return 1;
if (n == 2) return 2;
int ans = 1;
while (ans <= n) {
ans <<= 1;
}
return ans;
}
}
"""
Problem: LeetCode 3513 - Number of Unique XOR Triplets I
Difficulty: Medium
Language: Python
Author: CodeByTushu
"""
from typing import List
class Solution:
def uniqueXorTriplets(self, nums: List[int]) -> int:
n = len(nums)
if n == 1:
return 1
if n == 2:
return 2
ans = 1
while ans <= n:
ans <<= 1
return ans
/**
* Problem: LeetCode 3513 - Number of Unique XOR Triplets I
* Difficulty: Medium
* Language: C++
* Author: CodeByTushu
*/
#include <vector>
/**
* Problem: LeetCode 3513 - Number of Unique XOR Triplets I
* Difficulty: Medium
* Language: C++
* Author: CodeByTushu
*/
class Solution {
public:
int uniqueXorTriplets(std::vector<int>& nums) {
int n = nums.size();
if (n == 1) return 1;
if (n == 2) return 2;
int ans = 1;
while (ans <= n) {
ans <<= 1;
}
return ans;
}
};
/**
* Problem: LeetCode 3513 - Number of Unique XOR Triplets I
* Difficulty: Medium
* Language: JavaScript
* Author: CodeByTushu
*/
var uniqueXorTriplets = function(nums) {
const n = nums.length;
if (n === 1) return 1;
if (n === 2) return 2;
let ans = 1;
while (ans <= n) {
ans <<= 1;
}
return ans;
};