{ "data": { "question": { "questionId": "1768", "questionFrontendId": "1628", "boundTopicId": null, "title": "Design an Expression Tree With Evaluate Function", "titleSlug": "design-an-expression-tree-with-evaluate-function", "content": null, "translatedTitle": null, "translatedContent": null, "isPaidOnly": true, "difficulty": "Medium", "likes": 523, "dislikes": 71, "isLiked": null, "similarQuestions": "[{\"title\": \"Minimum Flips in Binary Tree to Get Result\", \"titleSlug\": \"minimum-flips-in-binary-tree-to-get-result\", \"difficulty\": \"Hard\", \"translatedTitle\": null}, {\"title\": \"Evaluate Boolean Binary Tree\", \"titleSlug\": \"evaluate-boolean-binary-tree\", \"difficulty\": \"Easy\", \"translatedTitle\": null}]", "exampleTestcases": "[\"3\",\"4\",\"+\",\"2\",\"*\",\"7\",\"/\"]\n[\"4\",\"5\",\"2\",\"7\",\"+\",\"-\",\"*\"]", "categoryTitle": "Algorithms", "contributors": [], "topicTags": [ { "name": "Math", "slug": "math", "translatedName": null, "__typename": "TopicTagNode" }, { "name": "Stack", "slug": "stack", "translatedName": null, "__typename": "TopicTagNode" }, { "name": "Tree", "slug": "tree", "translatedName": null, "__typename": "TopicTagNode" }, { "name": "Design", "slug": "design", "translatedName": null, "__typename": "TopicTagNode" }, { "name": "Binary Tree", "slug": "binary-tree", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": null, "stats": "{\"totalAccepted\": \"25.4K\", \"totalSubmission\": \"30.7K\", \"totalAcceptedRaw\": 25425, \"totalSubmissionRaw\": 30722, \"acRate\": \"82.8%\"}", "hints": [ "Apply the concept of Polymorphism to get a good design", "Implement the Node class using NumericNode and OperatorNode classes.", "NumericNode only maintains the value and evaluate returns this value.", "OperatorNode Maintains the left and right nodes representing the left and right operands, and the evaluate function applies the operator to them." ], "solution": null, "status": null, "sampleTestCase": "[\"3\",\"4\",\"+\",\"2\",\"*\",\"7\",\"/\"]", "metaData": "{\n \"name\": \"buildTree\",\n \"params\": [\n {\n \"name\": \"s\",\n \"type\": \"string[]\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n },\n \"manual\": true,\n \"languages\": [\n \"cpp\",\n \"java\",\n \"python\",\n \"csharp\",\n \"javascript\",\n \"python3\"\n ]\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [], "enableRunCode": true, "enableTestMode": false, "enableDebugger": true, "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 20 standard.

\\r\\n\\r\\n

Your code is compiled with level two optimization (-O2). AddressSanitizer is also enabled to help detect out-of-bounds and use-after-free bugs.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\"], \"java\": [\"Java\", \"

OpenJDK 17. Java 8 features such as lambda expressions and stream API can be used.

\\r\\n\\r\\n

Most standard library headers are already included automatically for your convenience.

\\r\\n

Includes Pair class from https://docs.oracle.com/javase/8/javafx/api/javafx/util/Pair.html.

\"], \"python\": [\"Python\", \"

Python 2.7.12.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\\r\\n\\r\\n

Note that Python 2.7 will not be maintained past 2020. For the latest Python, please choose Python3 instead.

\"], \"csharp\": [\"C#\", \"

C# 10 with .NET 6 runtime

\"], \"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use 5.3.0 version of datastructures-js/priority-queue and 4.2.1 version of datastructures-js/queue.

\"], \"python3\": [\"Python3\", \"

Python 3.10.

\\r\\n\\r\\n

Most libraries are already imported automatically for your convenience, such as array, bisect, collections. If you need more libraries, you can import it yourself.

\\r\\n\\r\\n

For Map/TreeMap data structure, you may use sortedcontainers library.

\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }