An O(n^2) C# solution is passing all the test cases. Is it normal? I think it should get TLE


  • 0
    K
    public class Solution {
        public int FindMaximumXOR(int[] nums) {
            int result = 0;
            int max = 0;
            for (int i=0;i<nums.Length;i++) {
                for (int j=i+1;j<nums.Length;j++) {
                    result = nums[i] ^ nums[j];
                    if (result > max) max = result;
                }
            }
            return max;
        }
    }
    

  • 0

    @kilicars Thanks. Now it gets TLE.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.