{"id":33892,"date":"2024-11-01T09:21:42","date_gmt":"2024-11-01T09:21:42","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=33892"},"modified":"2024-11-01T10:55:24","modified_gmt":"2024-11-01T10:55:24","slug":"c-coding-test-course-assigning-meeting-rooms","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/33892\/","title":{"rendered":"C# Coding Test Course, Assigning Meeting Rooms"},"content":{"rendered":"<p><body><\/p>\n<p>This course explains step-by-step how to solve the meeting room assignment problem using C#. The meeting room assignment problem enhances algorithmic thinking and is a common topic in various coding tests.<\/p>\n<h2>Problem Definition<\/h2>\n<p>Given the start and end times of meetings, each meeting has a specific start and end time, and they cannot occur simultaneously. The problem is to find the minimum number of meeting rooms required to accommodate all given meetings.<\/p>\n<h3>Input<\/h3>\n<pre>\n    The first line contains the number of meetings <code>N<\/code>. (1 \u2264 <code>N<\/code> \u2264 10<sup>5<\/sup>)\n    The next <code>N<\/code> lines contain the start time <code>start<\/code> and end time <code>end<\/code> of each meeting, separated by a space. (0 \u2264 <code>start<\/code> &lt; <code>end<\/code> \u2264 10<sup>6<\/sup>)\n    <\/pre>\n<h3>Output<\/h3>\n<p>Print the number of meeting rooms required.<\/p>\n<h2>Example<\/h2>\n<pre>\n    Input Example:\n    3\n    0 30\n    5 10\n    15 20\n\n    Output Example:\n    2\n    <\/pre>\n<h2>Approach to Problem Solving<\/h2>\n<p>To solve this problem, you can use the following approach:<\/p>\n<ol>\n<li>First, sort all meetings based on their start and end times.<\/li>\n<li>Check each meeting in sequence and compare it with the end time of the currently used meeting room to determine if a new meeting can start.<\/li>\n<li>If a new meeting can start, update the end time of the meeting room; otherwise, prepare to use a new meeting room.<\/li>\n<li>Finally, return the number of meeting rooms used.<\/li>\n<\/ol>\n<h2>C# Code Implementation<\/h2>\n<pre><code>\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass Program {\n    static void Main() {\n        int n = int.Parse(Console.ReadLine());\n        List&lt;(int start, int end)&gt; meetings = new List&lt;(int start, int end)&gt;();\n\n        for (int i = 0; i &lt; n; i++) {\n            var parts = Console.ReadLine().Split(' ');\n            int start = int.Parse(parts[0]);\n            int end = int.Parse(parts[1]);\n            meetings.Add((start, end));\n        }\n\n        \/\/ Sort meeting times based on end time\n        meetings.Sort((a, b) =&gt; a.end.CompareTo(b.end));\n\n        \/\/ Variable to count the number of meeting rooms\n        int roomCount = 0;\n        PriorityQueue<int, int=\"\"> minHeap = new PriorityQueue<int, int=\"\">(); \/\/ Using priority queue\n\n        foreach (var meeting in meetings) {\n            \/\/ If the current meeting's start time is greater than or equal to the end time of the meeting room that ends first\n            if (minHeap.Count &gt; 0 &amp;&amp; minHeap.Peek() &lt;= meeting.start) {\n                minHeap.Dequeue(); \/\/ Reuse meeting room\n            }\n            \/\/ Use a new meeting room\n            minHeap.Enqueue(meeting.end, meeting.end);\n        }\n\n        roomCount = minHeap.Count; \/\/ Number of remaining meeting rooms\n        Console.WriteLine(roomCount);\n    }\n}\n    <\/int,><\/int,><\/code><\/pre>\n<h2>Explanation<\/h2>\n<p>The above algorithm is generally classified as a greedy algorithm. It checks the currently ending meeting rooms while processing each meeting to use the minimum number of meeting rooms. A priority queue is used to efficiently manage the currently used meeting rooms. This algorithm derives the optimal result through the following procedure:<\/p>\n<h3>Time Complexity Analysis<\/h3>\n<p>The main Time Complexity of the algorithm is O(N log N). This is the time required to sort the list of meetings. The subsequent process of checking each meeting takes O(N), resulting in a total time complexity of O(N log N).<\/p>\n<h3>Space Complexity Analysis<\/h3>\n<p>The space complexity is O(N). This is due to storing meeting information in the list and the priority queue.<\/p>\n<h2>Conclusion<\/h2>\n<p>In this course, we explored the solution to the meeting room assignment problem using C#. By solving this problem, we learned the appropriate use of greedy algorithms and the efficient use of priority queues. There may be various meeting room assignment problems, so practice solving more problems to improve your skills.<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This course explains step-by-step how to solve the meeting room assignment problem using C#. The meeting room assignment problem enhances algorithmic thinking and is a common topic in various coding tests. Problem Definition Given the start and end times of meetings, each meeting has a specific start and end time, and they cannot occur simultaneously. &hellip; <a href=\"https:\/\/atmokpo.com\/w\/33892\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;C# Coding Test Course, Assigning Meeting Rooms&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[90],"tags":[],"class_list":["post-33892","post","type-post","status-publish","format-standard","hentry","category-c-coding-test-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C# Coding Test Course, Assigning Meeting Rooms - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/33892\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C# Coding Test Course, Assigning Meeting Rooms - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"This course explains step-by-step how to solve the meeting room assignment problem using C#. The meeting room assignment problem enhances algorithmic thinking and is a common topic in various coding tests. Problem Definition Given the start and end times of meetings, each meeting has a specific start and end time, and they cannot occur simultaneously. &hellip; \ub354 \ubcf4\uae30 &quot;C# Coding Test Course, Assigning Meeting Rooms&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/33892\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:21:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T10:55:24+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/33892\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33892\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"C# Coding Test Course, Assigning Meeting Rooms\",\"datePublished\":\"2024-11-01T09:21:42+00:00\",\"dateModified\":\"2024-11-01T10:55:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33892\/\"},\"wordCount\":348,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"C# Coding Test Tutorials\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/33892\/\",\"url\":\"https:\/\/atmokpo.com\/w\/33892\/\",\"name\":\"C# Coding Test Course, Assigning Meeting Rooms - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:21:42+00:00\",\"dateModified\":\"2024-11-01T10:55:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33892\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/33892\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/33892\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C# Coding Test Course, Assigning Meeting Rooms\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C# Coding Test Course, Assigning Meeting Rooms - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/33892\/","og_locale":"ko_KR","og_type":"article","og_title":"C# Coding Test Course, Assigning Meeting Rooms - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"This course explains step-by-step how to solve the meeting room assignment problem using C#. The meeting room assignment problem enhances algorithmic thinking and is a common topic in various coding tests. Problem Definition Given the start and end times of meetings, each meeting has a specific start and end time, and they cannot occur simultaneously. &hellip; \ub354 \ubcf4\uae30 \"C# Coding Test Course, Assigning Meeting Rooms\"","og_url":"https:\/\/atmokpo.com\/w\/33892\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:21:42+00:00","article_modified_time":"2024-11-01T10:55:24+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/33892\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/33892\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"C# Coding Test Course, Assigning Meeting Rooms","datePublished":"2024-11-01T09:21:42+00:00","dateModified":"2024-11-01T10:55:24+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/33892\/"},"wordCount":348,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["C# Coding Test Tutorials"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/33892\/","url":"https:\/\/atmokpo.com\/w\/33892\/","name":"C# Coding Test Course, Assigning Meeting Rooms - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:21:42+00:00","dateModified":"2024-11-01T10:55:24+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/33892\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/33892\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/33892\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"C# Coding Test Course, Assigning Meeting Rooms"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=33892"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33892\/revisions"}],"predecessor-version":[{"id":33893,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33892\/revisions\/33893"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=33892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=33892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=33892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}