{"id":33303,"date":"2024-11-01T09:15:21","date_gmt":"2024-11-01T09:15:21","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=33303"},"modified":"2024-11-01T11:39:16","modified_gmt":"2024-11-01T11:39:16","slug":"java-coding-test-course-i-dont-want-to-be-a-liar","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/33303\/","title":{"rendered":"Java Coding Test Course, I Don&#8217;t Want to Be a Liar"},"content":{"rendered":"<p><body><\/p>\n<header>\n<\/header>\n<p><main><\/p>\n<section>\n<h2>Problem Description<\/h2>\n<p>\n                You are preparing for a coding test for hiring new employees. The coding test problem is<br \/>\n                centered around the theme of &#8216;I Don&#8217;t Want to Be a Liar&#8217;. In this problem, you need to determine<br \/>\n                if someone is lying based on the stories of several employees. You must develop an algorithm to<br \/>\n                clearly distinguish who is telling the truth and who is lying in the workplace.\n            <\/p>\n<h3>Problem Content<\/h3>\n<p>\n                There are N employees. Each employee (A, B, C, &#8230;) claims about another employee, stating<br \/>\n                things like &#8216;A is a liar&#8217; or &#8216;B is a liar&#8217;. The claims of each employee are all trustworthy, and<br \/>\n                if a claim is incorrect, it generally becomes a lie.\n            <\/p>\n<h3>Input<\/h3>\n<ul>\n<li>The first line contains the number of employees N (1 \u2264 N \u2264 1000).<\/li>\n<li>The following N lines provide information about each employee&#8217;s claims. Each claim is in the format &#8220;This employee is a liar&#8221;.<\/li>\n<\/ul>\n<h3>Output<\/h3>\n<p>\n                Output the number of the employee who has lied the most. If there is only one employee who did not lie,<br \/>\n                output 0.\n            <\/p>\n<\/section>\n<section>\n<h2>Problem Solving Process<\/h2>\n<p>\n                To solve this problem, you need to analyze the relationships between employees and calculate<br \/>\n                the number of employees who are lying based on the claims of each employee. Here, we need to<br \/>\n                understand how each employee&#8217;s claims are connected.\n            <\/p>\n<h3>Step 1: Data Structure Design<\/h3>\n<p>\n                First, we need to choose a data structure that can store each employee&#8217;s claims. We can use a<br \/>\n                Map where the employee&#8217;s number is the key and the value is a list of the employees they claim are liars.\n            <\/p>\n<p>\n                For example, if employee 1 claims that employee 2 is a liar, the Map would look like this:\n            <\/p>\n<pre>\n                {\n                    1: [2],\n                    2: [3, 4],\n                    3: [1],\n                    ...\n                }\n            <\/pre>\n<h3>Step 2: Graph Traversal (DFS or BFS)<\/h3>\n<p>\n                Once the Map structure is ready, we need to determine who is telling the truth and who is<br \/>\n                lying through graph traversal. We can use DFS (Depth-First Search) or<br \/>\n                BFS (Breadth-First Search) algorithms for this purpose.\n            <\/p>\n<h3>Step 3: Calculate Results Based on Collected Data<\/h3>\n<p>\n                After the traversal is complete, calculate who has lied the most based on the information<br \/>\n                about whether each employee is lying.\n            <\/p>\n<h3>Step 4: Write Overall Code<\/h3>\n<p>\n                We will implement the above steps in code using Java. Below is an example code to solve<br \/>\n                the problem:\n            <\/p>\n<pre>\n                <code>\n                    import java.util.*;\n\n                    public class Main {\n                        public static void main(String[] args) {\n                            Scanner scanner = new Scanner(System.in);\n                            int n = scanner.nextInt();\n                            Map<Integer, List<Integer>> statements = new HashMap<>();\n\n                            \/\/ Inputting employee claims\n                            for (int i = 1; i <= n; i++) {\n                                int liarIndex = scanner.nextInt();\n                                if (!statements.containsKey(i)) {\n                                    statements.put(i, new ArrayList<>());\n                                }\n                                statements.get(i).add(liarIndex);\n                            }\n\n                            int maxLiars = 0;\n\n                            \/\/ Calculate the number of liars for each employee\n                            for (int i = 1; i <= n; i++) {\n                                HashSet<Integer> visited = new HashSet<>();\n                                boolean[] isLiar = new boolean[n + 1];\n                                isLiar[i] = true;\n\n                                dfs(i, statements, visited, isLiar);\n\n                                int countLiars = 0;\n                                for (int j = 1; j <= n; j++) {\n                                    if (isLiar[j]) countLiars++;\n                                }\n                                maxLiars = Math.max(maxLiars, countLiars);\n                            }\n                            System.out.println(maxLiars);\n                        }\n\n                        private static void dfs(int employee, Map<Integer, List<Integer>> statements, \n                                                HashSet<Integer> visited, boolean[] isLiar) {\n                            if (visited.contains(employee)) return;\n                            visited.add(employee);\n\n                            if (statements.containsKey(employee)) {\n                                for (int liar : statements.get(employee)) {\n                                    isLiar[liar] = true;\n                                    dfs(liar, statements, visited, isLiar);\n                                }\n                            }\n                        }\n                    }\n                <\/code>\n            <\/pre>\n<h2>Conclusion<\/h2>\n<p>\n                In this body, we defined the problem centered around &#8216;I Don&#8217;t Want to Be a Liar&#8217;<br \/>\n                and explained the algorithm to solve that problem step by step.<br \/>\n                By analyzing the information about the claims of employees, we can determine who has lied,<br \/>\n                and through those results, we can identify the employee who has lied the most.<br \/>\n                This process can help improve your preparation for coding tests and your problem-solving skills in algorithms.\n            <\/p>\n<\/section>\n<p><\/main><br \/>\n<\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Description You are preparing for a coding test for hiring new employees. The coding test problem is centered around the theme of &#8216;I Don&#8217;t Want to Be a Liar&#8217;. In this problem, you need to determine if someone is lying based on the stories of several employees. You must develop an algorithm to clearly &hellip; <a href=\"https:\/\/atmokpo.com\/w\/33303\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Java Coding Test Course, I Don&#8217;t Want to Be a Liar&#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-33303","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, I Don&#039;t Want to Be a Liar - \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\/33303\/\" \/>\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, I Don&#039;t Want to Be a Liar - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Problem Description You are preparing for a coding test for hiring new employees. The coding test problem is centered around the theme of &#8216;I Don&#8217;t Want to Be a Liar&#8217;. In this problem, you need to determine if someone is lying based on the stories of several employees. You must develop an algorithm to clearly &hellip; \ub354 \ubcf4\uae30 &quot;Java Coding Test Course, I Don&#8217;t Want to Be a Liar&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/33303\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:15:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:39:16+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=\"2\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/33303\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33303\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Java Coding Test Course, I Don&#8217;t Want to Be a Liar\",\"datePublished\":\"2024-11-01T09:15:21+00:00\",\"dateModified\":\"2024-11-01T11:39:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33303\/\"},\"wordCount\":454,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Java Coding Test\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/33303\/\",\"url\":\"https:\/\/atmokpo.com\/w\/33303\/\",\"name\":\"Java Coding Test Course, I Don't Want to Be a Liar - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:15:21+00:00\",\"dateModified\":\"2024-11-01T11:39:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33303\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/33303\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/33303\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Coding Test Course, I Don&#8217;t Want to Be a Liar\"}]},{\"@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, I Don't Want to Be a Liar - \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\/33303\/","og_locale":"ko_KR","og_type":"article","og_title":"Java Coding Test Course, I Don't Want to Be a Liar - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Problem Description You are preparing for a coding test for hiring new employees. The coding test problem is centered around the theme of &#8216;I Don&#8217;t Want to Be a Liar&#8217;. In this problem, you need to determine if someone is lying based on the stories of several employees. You must develop an algorithm to clearly &hellip; \ub354 \ubcf4\uae30 \"Java Coding Test Course, I Don&#8217;t Want to Be a Liar\"","og_url":"https:\/\/atmokpo.com\/w\/33303\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:15:21+00:00","article_modified_time":"2024-11-01T11:39:16+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":"2\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/33303\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/33303\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Java Coding Test Course, I Don&#8217;t Want to Be a Liar","datePublished":"2024-11-01T09:15:21+00:00","dateModified":"2024-11-01T11:39:16+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/33303\/"},"wordCount":454,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Java Coding Test"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/33303\/","url":"https:\/\/atmokpo.com\/w\/33303\/","name":"Java Coding Test Course, I Don't Want to Be a Liar - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:15:21+00:00","dateModified":"2024-11-01T11:39:16+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/33303\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/33303\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/33303\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Java Coding Test Course, I Don&#8217;t Want to Be a Liar"}]},{"@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\/33303","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=33303"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33303\/revisions"}],"predecessor-version":[{"id":33304,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33303\/revisions\/33304"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=33303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=33303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=33303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}