I took the online Amazon assessment test and here is the question I received. I would also like to know any logic to resolve this problem statement.
Problem Statement:
Given a pattern (0xFEDB6190), find the presence of it in a given array and the starting point/bit of the pattern occurrence. For example,
Case 1: data = {0x00, 0xfe, 0xdb, 0x61, 0x90, 0x23, 0x45, 0x00}. Here in this 'data' array the pattern is present and starting bit is 8. The pattern starts from 8th bit.
Case 2: data = {0x00, 0x01, 0xfd, 0xb6, 0xc3, 0x20, 0x23, 0x45}. Same data array as Case 1, but with left-shifted by 1. Here pattern is present and starting bit is 7.
Hint: Had provision to use htonl(), ntohl(); to convert from network order to host order and vice versa.
Any viable optimized solution for this ?