GROWW LLD ROUND

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2024-07-20Added By Anonymous
Source: Link
GROWW LLD ROUND

Expression Gate

You are given an expression that contains only logical operators and few operands as variables, and a map object which contains the operands value.

Build an application using OOPs concept where you evaluate the expression and return the boolean output for it

We should be able to add more operators without changing much of code

Operators: &&, ||, !=, <=, >=, ==

evaluate(String expression, Map<String, Object>)


Example

Input Expression: name == name && age <= 45 && location != NY

Input Object:
{
“name”: “name”,
“age”: 36,
“location”:”NY”
}

Output = false

Example

name == Bob && age <= 45 && location != NY

{
“name”: “Bob”,
“age”: 36,
“location”:”Boston”
}

Output : true
Comments