-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwiki.json
1 lines (1 loc) · 10.5 KB
/
wiki.json
1
[{"model": "wiki.article", "pk": 1, "fields": {"current_revision": 35, "created": "2019-10-12T09:19:33.394Z", "modified": "2019-10-14T20:10:52.563Z", "owner": null, "group": null, "group_read": true, "group_write": true, "other_read": true, "other_write": false}}, {"model": "wiki.article", "pk": 5, "fields": {"current_revision": 18, "created": "2019-10-13T00:23:46.388Z", "modified": "2019-10-14T20:10:37.744Z", "owner": null, "group": null, "group_read": true, "group_write": true, "other_read": true, "other_write": false}}, {"model": "wiki.article", "pk": 8, "fields": {"current_revision": 38, "created": "2019-10-14T20:09:03.758Z", "modified": "2019-10-18T22:02:03.097Z", "owner": null, "group": null, "group_read": true, "group_write": true, "other_read": true, "other_write": false}}, {"model": "wiki.article", "pk": 9, "fields": {"current_revision": 39, "created": "2019-10-18T21:57:56.829Z", "modified": "2019-10-18T22:32:27.750Z", "owner": null, "group": null, "group_read": true, "group_write": true, "other_read": true, "other_write": true}}, {"model": "wiki.articleforobject", "pk": 1, "fields": {"article": 1, "content_type": 29, "object_id": 1, "is_mptt": true}}, {"model": "wiki.articleforobject", "pk": 5, "fields": {"article": 5, "content_type": 29, "object_id": 5, "is_mptt": true}}, {"model": "wiki.articleforobject", "pk": 8, "fields": {"article": 8, "content_type": 29, "object_id": 8, "is_mptt": true}}, {"model": "wiki.articleforobject", "pk": 9, "fields": {"article": 9, "content_type": 29, "object_id": 9, "is_mptt": true}}, {"model": "wiki.articlerevision", "pk": 18, "fields": {"revision_number": 1, "user_message": "", "automatic_log": "", "ip_address": null, "user": null, "modified": "2019-10-14T20:09:37.218Z", "created": "2019-10-13T00:23:46.394Z", "previous_revision": null, "deleted": false, "locked": false, "article": 5, "content": "", "title": "team 0"}}, {"model": "wiki.articlerevision", "pk": 35, "fields": {"revision_number": 9, "user_message": "", "automatic_log": "", "ip_address": null, "user": null, "modified": "2019-10-14T20:09:46.801Z", "created": "2019-10-14T19:51:26.788Z", "previous_revision": null, "deleted": false, "locked": false, "article": 1, "content": "[article_list]\r\n\r\n## Introduction\r\n\r\nHello. The UPE bit-byte coding challenge 2019 takes the form of interview-style questions, the same kind that Facebook or Google might ask.\r\n\r\nWe are trying to start a database of questions and solutions. Your contributions will help us kick off this database, so please submit high-quality solutions!\r\n\r\nNote that \"high quality\" does not necessarily mean \"most efficient\"; it means clearly presented, understandable solutions with good explanations. Brute-force solutions are also valuable for teaching purposes :)\r\n\r\n## Instructions\r\n\r\nEach team gets a set of questions. The number of questions per team have been roughly weighted by difficulty (i.e. you can get anything from one very hard question, to several easier questions).\r\n\r\n1. Refer to the **Team Assignments** chart for your team's assignment. You'll need to know your byte's name.\r\n\r\n2. Look at the linked **Google Doc** for your challenge questions.\r\n\r\n3. For each question, **create a page** in this wiki at `root > team [team_number] > question [question_number]`. **Copy your question** from the doc to the top of this page. Then, **detail your team's solution** below. It's up to bytes how to distribute and delegate the questions among the bits. Some possible options:\r\n\r\n a. Have every bit collaborate on every question;\r\n\r\n b. Have every bit do every question individually, then merge them;\r\n\r\n c. Have every bit do non-overlapping work, then collate the solutions.\r\n\r\n **Note:** Bytes are expected to be present and helpful in the bits' endeavor to complete the challenge. We recommend meeting up to discuss the questions.\r\n\r\n4. There are several guidelines for solutions:\r\n\r\n a. Solutions must be either in Python or C++;\r\n\r\n b. Solution code must be self-documenting. This means you should put comments when doing anything non-obvious.\r\n\r\n5. In addition to the solution, each question must have at least **3 test cases**, in the form of input-output pairs. Try to come up with edge cases.\r\n\r\n6. If so desired, you can have **additional explanations and walk-throughs** of test cases. Although not strictly necessary, this is exactly what interviewers look for, so you might as well practice doing this.\r\n\r\n**Tip**: use a text editor / IDE on your computer to work on the problem. When you're done, copy the solution code to the relevant solution page.\r\n\r\n## Sample Solution\r\n\r\nWe have included a [sample solution](team-0/question-0/) in the wiki. Please follow the format specified as much as you can. You can copy the raw solution text by going to its edit tab.\r\n\r\n## Challenge Questions\r\n\r\n[**Google Docs link**](https://drive.google.com/open?id=1UGnBzkTlS2esS0wG_yHsnkDFi93Xnyq9DR88-jRyJAc)\r\n\r\n## Team Assignments\r\n\r\n```\r\nTeam 1 (Austin) : 1, 2, 3 \r\nTeam 2 (Alex) : 4, 5, 6 \r\nTeam 3 (Nikki) : 7 \r\nTeam 4 (Shrey) : 8, 9 \r\nTeam 5 (Quentin) : 10, 11 \r\nTeam 6 (Vincent) : 12, 13, 14\r\nTeam 7 (Vivek) : 15, 16 \r\nTeam 8 (Regina) : 17, 18, 19\r\nTeam 9 (Arpit) : 20, 21 \r\nTeam 10 (Rishan) : 22, 23 \r\nTeam 11 (Jay) : 24, 25, 26\r\nTeam 12 (Shikha) : 28, 29 \r\nTeam 13 (Jivan) : 30, 31, 32\r\nTeam 14 (Bradley) : 33, 34, 35\r\nTeam 15 (Tanish) : 36, 37, 38\r\nTeam 16 (Dennis) : 39, 40, 41\r\nTeam 17 (Julia) : 42, 43 \r\nTeam 18 (Daniel) : 44, 45 \r\nTeam 19 (Ken) : 46, 47 \r\nTeam 20 (Christopher) : 49, 50 \r\nTeam 21 (Sriram) : 27, 48 \r\n```\r\n\r\nRemember: teamwork makes the dream work. Good luck!", "title": "UPE Bit-Byte Coding Challenge 2019"}}, {"model": "wiki.articlerevision", "pk": 38, "fields": {"revision_number": 1, "user_message": "", "automatic_log": "", "ip_address": null, "user": null, "modified": "2019-10-14T20:09:53.832Z", "created": "2019-10-14T20:09:03.765Z", "previous_revision": null, "deleted": false, "locked": false, "article": 8, "content": "# Minimum Absolute Difference\r\n\r\n## Question\r\n\r\nGiven an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.\r\n\r\nReturn a list of pairs in ascending order(with respect to pairs), each pair `[a, b]` follows\r\n\r\n* `a, b` are from `arr`\r\n* `a < b`\r\n* `b - a` equals to the minimum absolute difference of any two elements in `arr`\r\n\r\n \r\n\r\n### Example 1:\r\n\r\nInput: `arr = [4,2,1,3]`\r\n\r\nOutput: `[[1,2],[2,3],[3,4]]`\r\n\r\nExplanation: The minimum absolute difference is 1. List all pairs with difference equal to 1 in ascending order.\r\n\r\n### Example 2:\r\n\r\nInput: `arr = [1,3,6,10,15]`\r\n\r\nOutput: `[[1,3]]`\r\n\r\n### Example 3:\r\n\r\nInput: `arr = [3,8,-10,23,19,-4,-14,27]`\r\n\r\nOutput: `[[-14,-10],[19,23],[23,27]]`\r\n\r\nConstraints:\r\n\r\n* `2 <= arr.length <= 10^5`\r\n* `-10^6 <= arr[i] <= 10^6`\r\n\r\n\r\n\r\n## Solution\r\n\r\n```C++\r\nclass Solution {\r\npublic:\r\n vector<vector<int>> minimumAbsDifference(vector<int>& arr) {\r\n // pre-sort\r\n sort(arr.begin(), arr.end());\r\n vector<vector<int>> ret;\r\n int smallest = arr[1] - arr[0];\r\n\r\n // iterate through pre-sorted array once\r\n for (int i = 0; i < arr.size()-1; ++i) {\r\n int diff = arr[i+1] - arr[i];\r\n if (diff <= smallest) {\r\n // new min abs diff: reset return vector\r\n if (diff < smallest) {\r\n ret.clear();\r\n smallest = diff;\r\n }\r\n // add to return vector\r\n vector<int> a = {arr[i], arr[i+1]};\r\n ret.push_back(a);\r\n }\r\n }\r\n return ret;\r\n }\r\n};\r\n```\r\n\r\nExplanation:\r\n\r\nFirst, pre-sort the array. This is a good idea because:\r\n\r\n1. The returned list must be in ascending order, and\r\n\r\n2. The minimum absolute difference between `x` and any other number must involve `x`'s adjacent numbers in the sorted list. Another way to put it: The minimum absolute difference between `x` and any other number must involve either (1) the smallest number bigger than `x`, or (2) the biggest number smaller than `x`. These two numbers are easy to access once we sort the list (they will be the two numbers adjacent to x).\r\n\r\nThen, run though the sorted array while keeping track of the size of minimum difference in `smallest`. Populate the return array `ret` as we go along. If we find a smaller minimum difference, throw away the current values in `ret` and populate it again with the new `smallest`.\r\n\r\nWe are guaranteed to find only and all the elements we want, because there is only one minimum value of `smallest`, which will be discovered when checking the first pair in the sorted list whose absolute difference equals `smallest`. From then on, every later pair of numbers with absolute difference `smallest` will be discovered and included in `ret`, while every other pair has difference greater than `smallest`, so they will not be included in `ret`.\r\n\r\n---\r\n\r\nTime complexity: O(nlogn).\r\n\r\nThe pre-sort takes O(nlogn) time. Then we go through the array linearly once, which takes O(n).\r\n\r\nSpace complexity: O(n).\r\n\r\nThe return vector takes O(n) additional space.", "title": "question 0"}}, {"model": "wiki.articlerevision", "pk": 39, "fields": {"revision_number": 1, "user_message": "", "automatic_log": "", "ip_address": null, "user": 1, "modified": "2019-10-18T21:57:56.842Z", "created": "2019-10-18T21:57:56.842Z", "previous_revision": null, "deleted": false, "locked": false, "article": 9, "content": "", "title": "Solutions"}}, {"model": "wiki.urlpath", "pk": 1, "fields": {"article": 1, "slug": null, "site": 1, "parent": null, "moved_to": null, "lft": 1, "rght": 18, "tree_id": 1, "level": 0}}, {"model": "wiki.urlpath", "pk": 5, "fields": {"article": 5, "slug": "team-0", "site": 1, "parent": 9, "moved_to": null, "lft": 11, "rght": 16, "tree_id": 1, "level": 2}}, {"model": "wiki.urlpath", "pk": 8, "fields": {"article": 8, "slug": "question-0", "site": 1, "parent": 5, "moved_to": null, "lft": 14, "rght": 15, "tree_id": 1, "level": 3}}, {"model": "wiki.urlpath", "pk": 9, "fields": {"article": 9, "slug": "solutions", "site": 1, "parent": 1, "moved_to": null, "lft": 10, "rght": 17, "tree_id": 1, "level": 1}}]