String Comparision - Amazon , Walmart , Google , Microsoft

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2022-01-11Added By Anonymous
Source: Link

How to compare two strings are equal or not with logical operators in between those strings. These strings are table columns ?


Let's say countrycode , domainNumber , employeeType are the columns of the table . We want to compare the expressions that are formed by these columns with logical operators in between in any order are not same .


Example 1 :

str1: (country_code ='US' AND domain_num ='5' OR employee_type ='FT')

str2 : (country_code ='US' OR domain_num ='5' AND employee_type ='FT')


1Answer : False 2 3 4Example 2 : 5 6(employee_type = 'P' AND (domain_num = '1' or domain_num = '3') AND country_code = 'US') 7 8(country_code = 'US' AND (domain_num = '1' or domain_num = '3') AND employee_type = 'P') 9 10Answer : True 11 12 Example 2 : 13 14(employee_type = 'P' AND (domain_num = '3' or domain_num = '1') AND country_code = 'US') 15 16(country_code = 'US' AND (domain_num = '1' AND domain_num = '3') AND employee_type = 'P') 17 18Answer : False


Comments