{"id":33518,"date":"2024-11-01T09:17:23","date_gmt":"2024-11-01T09:17:23","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=33518"},"modified":"2024-11-01T11:38:13","modified_gmt":"2024-11-01T11:38:13","slug":"java-coding-test-course-making-cocktails","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/33518\/","title":{"rendered":"Java Coding Test Course, Making Cocktails"},"content":{"rendered":"<p><body><\/p>\n<p>The coding test is an important element to evaluate the ability to solve realistic problems. In this course, we will address an algorithm problem with the theme of &#8216;Making Cocktails&#8217; and explain the necessary concepts and methodologies in detail and systematically.<\/p>\n<h2>Problem Description<\/h2>\n<p>As a bartender at a bar, you can make various cocktails using different ingredients. Each cocktail requires different ingredients. Your task is to write a program that determines whether you can make each cocktail based on the given ingredients.<\/p>\n<h3>Problem Definition<\/h3>\n<p>Given a list of available ingredients and a list of cocktails, check whether the ingredients needed to make each cocktail are included in the given list.<\/p>\n<h3>Input<\/h3>\n<ul>\n<li>List A: Available ingredients (string array)<\/li>\n<li>List B: Cocktails you want to make (string array, each cocktail lists the required ingredients)<\/li>\n<\/ul>\n<h3>Output<\/h3>\n<p>Return an array that outputs whether each cocktail can be made as <code>true<\/code> or <code>false<\/code>.<\/p>\n<h3>Example<\/h3>\n<pre>\nInput:\nA = [\"Gin\", \"Puff\", \"Lemon\", \"Soda\"]\nB = [\"Gin Tonic\", \"Puff Drink\", \"Mojito\"]\n\nOutput:\n[true, true, false]\n<\/pre>\n<h2>Problem Solving Process<\/h2>\n<p>To solve this problem, you can approach it in the following steps.<\/p>\n<h3>1. Choose Data Structure<\/h3>\n<p>First, it would be good to convert the list A of available ingredients into a <code>Set<\/code> structure. <code>Set<\/code> does not allow duplicates and can check the existence of elements in <code>O(1)<\/code> time complexity. This allows us to quickly check the inclusion of ingredients.<\/p>\n<h3>2. Check Cocktail Ingredients<\/h3>\n<p>When checking the ingredients needed to make each cocktail, you need to split each cocktail string by spaces to obtain the list of ingredients and determine if all ingredients in this list are included in A. This process is repeated to check all cocktails.<\/p>\n<h3>3. Implementation<\/h3>\n<p>Now let&#8217;s implement this in Java. Below is the complete code:<\/p>\n<pre><code>import java.util.HashSet;\nimport java.util.Set;\n\npublic class CocktailMaker {\n    public static boolean[] canMakeCocktails(String[] availableIngredients, String[] cocktails) {\n        \/\/ Add available ingredients to Set\n        Set&lt;String&gt; ingredientsSet = new HashSet&lt;&gt;();\n        for (String ingredient : availableIngredients) {\n            ingredientsSet.add(ingredient);\n        }\n\n        boolean[] results = new boolean[cocktails.length];\n\n        \/\/ Check the ingredients for each cocktail\n        for (int i = 0; i &lt; cocktails.length; i++) {\n            String[] requiredIngredients = cocktails[i].split(\" \");\n            boolean canMake = true;\n\n            for (String ingredient : requiredIngredients) {\n                if (!ingredientsSet.contains(ingredient)) {\n                    canMake = false;\n                    break;\n                }\n            }\n            results[i] = canMake;\n        }\n\n        return results;\n    }\n\n    public static void main(String[] args) {\n        String[] A = {\"Gin\", \"Puff\", \"Lemon\", \"Soda\"};\n        String[] B = {\"Gin Tonic\", \"Puff Drink\", \"Mojito\"};\n\n        boolean[] result = canMakeCocktails(A, B);\n        for (boolean res : result) {\n            System.out.print(res + \" \");\n        }\n    }\n}\n<\/code><\/pre>\n<h3>4. Performance Evaluation<\/h3>\n<p>The time complexity of this algorithm is as follows:<\/p>\n<ul>\n<li>Adding ingredients to the <code>Set<\/code>: <code>O(m)<\/code> (m is the length of A)<\/li>\n<li>Checking the ingredients for each cocktail: <code>O(n * k)<\/code> (n is the length of B, k is the average number of ingredients for each cocktail)<\/li>\n<\/ul>\n<p>Therefore, the overall time complexity is <code>O(m + n * k)<\/code>, which is sufficiently efficient.<\/p>\n<h2>Conclusion<\/h2>\n<p>In this way, you can write a program to determine whether cocktails can be made or not. In coding tests, it is important to thoroughly analyze problems like this and find the optimal solution. It is necessary to understand the problem well and practice implementing it step by step. Learn various approaches and optimization strategies.<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The coding test is an important element to evaluate the ability to solve realistic problems. In this course, we will address an algorithm problem with the theme of &#8216;Making Cocktails&#8217; and explain the necessary concepts and methodologies in detail and systematically. Problem Description As a bartender at a bar, you can make various cocktails using &hellip; <a href=\"https:\/\/atmokpo.com\/w\/33518\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Java Coding Test Course, Making Cocktails&#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":[139],"tags":[],"class_list":["post-33518","post","type-post","status-publish","format-standard","hentry","category-java-coding-test"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Coding Test Course, Making Cocktails - \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\/33518\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Coding Test Course, Making Cocktails - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"The coding test is an important element to evaluate the ability to solve realistic problems. In this course, we will address an algorithm problem with the theme of &#8216;Making Cocktails&#8217; and explain the necessary concepts and methodologies in detail and systematically. Problem Description As a bartender at a bar, you can make various cocktails using &hellip; \ub354 \ubcf4\uae30 &quot;Java Coding Test Course, Making Cocktails&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/33518\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:17:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:38:13+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\/33518\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33518\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Java Coding Test Course, Making Cocktails\",\"datePublished\":\"2024-11-01T09:17:23+00:00\",\"dateModified\":\"2024-11-01T11:38:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33518\/\"},\"wordCount\":380,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Java Coding Test\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/33518\/\",\"url\":\"https:\/\/atmokpo.com\/w\/33518\/\",\"name\":\"Java Coding Test Course, Making Cocktails - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:17:23+00:00\",\"dateModified\":\"2024-11-01T11:38:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33518\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/33518\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/33518\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Coding Test Course, Making Cocktails\"}]},{\"@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":"Java Coding Test Course, Making Cocktails - \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\/33518\/","og_locale":"ko_KR","og_type":"article","og_title":"Java Coding Test Course, Making Cocktails - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"The coding test is an important element to evaluate the ability to solve realistic problems. In this course, we will address an algorithm problem with the theme of &#8216;Making Cocktails&#8217; and explain the necessary concepts and methodologies in detail and systematically. Problem Description As a bartender at a bar, you can make various cocktails using &hellip; \ub354 \ubcf4\uae30 \"Java Coding Test Course, Making Cocktails\"","og_url":"https:\/\/atmokpo.com\/w\/33518\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:17:23+00:00","article_modified_time":"2024-11-01T11:38:13+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\/33518\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/33518\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Java Coding Test Course, Making Cocktails","datePublished":"2024-11-01T09:17:23+00:00","dateModified":"2024-11-01T11:38:13+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/33518\/"},"wordCount":380,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Java Coding Test"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/33518\/","url":"https:\/\/atmokpo.com\/w\/33518\/","name":"Java Coding Test Course, Making Cocktails - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:17:23+00:00","dateModified":"2024-11-01T11:38:13+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/33518\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/33518\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/33518\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Java Coding Test Course, Making Cocktails"}]},{"@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\/33518","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=33518"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33518\/revisions"}],"predecessor-version":[{"id":33519,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33518\/revisions\/33519"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=33518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=33518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=33518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}