NVIDIA Interview Question

Check if two strings are permutations of each other

Interview Answer

Anonymous

Oct 1, 2021

If arrayA length arrayB length return False Create fixed integer array size of 256 (to be used as hash table) // Fixed sized array considered O(1) Zero the array For string A increment hash[array_A[i]] For string B if hash[array_B[i]] > 0 decrement hash[array[i]] else return False If any hash[i] > 0 return False return True

1