{ "data": { "question": { "questionId": "1655", "questionFrontendId": "1516", "boundTopicId": null, "title": "Move Sub-Tree of N-Ary Tree", "titleSlug": "move-sub-tree-of-n-ary-tree", "content": null, "translatedTitle": null, "translatedContent": null, "isPaidOnly": true, "difficulty": "Hard", "likes": 24, "dislikes": 36, "isLiked": null, "similarQuestions": "[{\"title\": \"Find Root of N-Ary Tree\", \"titleSlug\": \"find-root-of-n-ary-tree\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]", "exampleTestcases": "[1,null,2,3,null,4,5,null,6,null,7,8]\n4\n1\n[1,null,2,3,null,4,5,null,6,null,7,8]\n7\n4\n[1,null,2,3,null,4,5,null,6,null,7,8]\n3\n8", "categoryTitle": "Algorithms", "contributors": [], "topicTags": [ { "name": "Tree", "slug": "tree", "translatedName": null, "__typename": "TopicTagNode" }, { "name": "Depth-First Search", "slug": "depth-first-search", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": null, "stats": "{\"totalAccepted\": \"1.7K\", \"totalSubmission\": \"2.7K\", \"totalAcceptedRaw\": 1740, \"totalSubmissionRaw\": 2682, \"acRate\": \"64.9%\"}", "hints": [ "Disconnect node p from its parent and append it to the children list of node q.", "If q was in the sub-tree of node p (case 1), get the parent node of p and replace p in its children list with q.", "If p was the root of the tree, make q the root of the tree." ], "solution": null, "status": null, "sampleTestCase": "[1,null,2,3,null,4,5,null,6,null,7,8]\n4\n1", "metaData": "{\n \"name\": \"moveSubTree\",\n \"params\": [\n {\n \"name\": \"root\",\n \"type\": \"integer\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"p\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"q\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n },\n \"manual\": true,\n \"languages\": [\n \"cpp\",\n \"java\",\n \"python\",\n \"csharp\",\n \"javascript\",\n \"ruby\",\n \"swift\",\n \"golang\",\n \"python3\",\n \"scala\",\n \"kotlin\",\n \"php\",\n \"typescript\"\n ]\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [], "enableRunCode": true, "enableTestMode": false, "enableDebugger": true, "envInfo": "{\"cpp\": [\"C++\", \"

Compiled with clang 11 using the latest C++ 17 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

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

Your code is compiled with debug flag enabled (/debug).

\"], \"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 datastructures-js/priority-queue and datastructures-js/queue.

\"], \"ruby\": [\"Ruby\", \"

Ruby 3.1

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

Some common data structure implementations are provided in the Algorithms module: https://www.rubydoc.info/github/kanwei/algorithms/Algorithms

\"], \"swift\": [\"Swift\", \"

Swift 5.5.2.

\"], \"golang\": [\"Go\", \"

Go 1.17.6.

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

Support https://godoc.org/github.com/emirpasic/gods library.

\"], \"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.

\"], \"scala\": [\"Scala\", \"

Scala 2.13.7.

\"], \"kotlin\": [\"Kotlin\", \"

Kotlin 1.3.10.

\"], \"php\": [\"PHP\", \"

PHP 8.1.

\\r\\n

With bcmath module

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

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

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

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

lodash.js library is included by default.

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