{"id":35146,"date":"2024-11-01T09:36:06","date_gmt":"2024-11-01T09:36:06","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=35146"},"modified":"2024-11-01T12:40:13","modified_gmt":"2024-11-01T12:40:13","slug":"%ec%bd%94%ed%8b%80%eb%a6%b0-%ec%bd%94%eb%94%a9%ed%85%8c%ec%8a%a4%ed%8a%b8-%ea%b0%95%ec%a2%8c-%ec%b5%9c%ec%86%9f%ea%b0%92%ec%9d%84-%eb%a7%8c%eb%93%9c%eb%8a%94-%ea%b4%84%ed%98%b8-%eb%b0%b0%ec%b9%98-2","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/35146\/","title":{"rendered":"Kotlin coding test course, finding the parenthesis placement to minimize the value"},"content":{"rendered":"<p><body><\/p>\n<p>\n        Coding tests and algorithm problems come in various types and difficulties. In this course, we will explore how to arrange parentheses to minimize an expression. This problem asks how efficiently we can calculate an expression through the placement of parentheses.\n    <\/p>\n<h2>Problem Description<\/h2>\n<p>\n        This is a problem of finding an arrangement of parentheses that minimizes an expression made up of given numbers and operators.<br \/>\n        For example, given the expression &#8220;2 &#8211; 3 + 5&#8221;, we need to appropriately place parentheses to compute the minimum value.<br \/>\n        Parentheses can be freely placed around each operator, and the goal is to minimize the resulting value.\n    <\/p>\n<h3>Input<\/h3>\n<p>\n        The expression is given as a string and consists of only the operators + and -. The expression does not contain spaces.<br \/>\n        The length of the expression is between 1 and 50 characters.\n    <\/p>\n<h3>Output<\/h3>\n<p>\n        The output is the minimum value calculated by appropriately placing parentheses.\n    <\/p>\n<h2>Problem Solving Process<\/h2>\n<p>\n        To solve the problem, we can use either Dynamic Programming or Divide and Conquer techniques.<br \/>\n        Here, we will use the Divide and Conquer approach to solve the problem.\n    <\/p>\n<h3>Step 1: Parsing the Input<\/h3>\n<p>\n        To solve the problem, we first need to separate the input expression into numbers and operators.<br \/>\n        The numbers in the expression will be integers, and the operators will be either &#8216;+&#8217; or &#8216;-&#8216;.<br \/>\n        Thus, by iterating through the string, we will add numbers to a number array and operators to an operator array when encountered.\n    <\/p>\n<h3>Step 2: Considering All Possible Cases<\/h3>\n<p>\n        Next, we must consider all possible arrangements of parentheses and calculate the minimum value of the expression.<br \/>\n        To do this, we will split the expression into left and right parts for each operator and find their respective minimum values.<br \/>\n        By applying the operator to the minimum values from both sides, we can derive a new value and find the minimum among them.\n    <\/p>\n<h3>Step 3: Recursive Approach<\/h3>\n<p>\n        By implementing the above process recursively, we can break down the problem into subproblems and solve them.<br \/>\n        At each step, the expression is split based on the operator, and the minimum values for the left and right parts are calculated.\n    <\/p>\n<h3>Example Code<\/h3>\n<pre>\n        <code>\n            fun findMinimumValue(expression: String): Int {\n                val numbers = mutableListOf<int>()\n                val operators = mutableListOf<char>()\n                var num = StringBuilder()\n\n                \/\/ Parsing the expression\n                for (char in expression) {\n                    when {\n                        char.isDigit() -> num.append(char)\n                        char == '+' || char == '-' -> {\n                            numbers.add(num.toString().toInt())\n                            operators.add(char)\n                            num = StringBuilder()\n                        }\n                    }\n                }\n                \/\/ Adding the last number\n                if (num.isNotEmpty()) {\n                    numbers.add(num.toString().toInt())\n                }\n\n                return calculateMinimum(numbers, operators, 0, numbers.size - 1)\n            }\n\n            fun calculateMinimum(numbers: List<int>, operators: List<char>, start: Int, end: Int): Int {\n                if (start == end) return numbers[start]\n\n                var minValue = Int.MAX_VALUE\n\n                for (i in start until end) {\n                    val leftMin = calculateMinimum(numbers, operators, start, i)\n                    val rightMin = calculateMinimum(numbers, operators, i + 1, end)\n\n                    val result = when (operators[i]) {\n                        '+' -> leftMin + rightMin\n                        '-' -> leftMin - rightMin\n                        else -> throw IllegalArgumentException(\"Unsupported operator: ${operators[i]}\")\n                    }\n\n                    minValue = minOf(minValue, result)\n                }\n\n                return minValue\n            }\n\n            fun main() {\n                val expression = \"2-3+5\"\n                val result = findMinimumValue(expression)\n                println(\"Minimum value: $result\")\n            }\n        <\/char><\/int><\/char><\/int><\/code>\n    <\/pre>\n<h2>Conclusion<\/h2>\n<p>\n        In this course, we tackled the problem of arranging parentheses to minimize an expression.<br \/>\n        Although there are various approaches to solving such problems, we used recursive and divide and conquer methods here.<br \/>\n        If you encounter such problems in actual coding tests, it is crucial to thoroughly analyze the problem and approach it with an efficient and clear algorithm.<br \/>\n        We encourage you to continue seeking solutions to various problems in the future.\n    <\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Coding tests and algorithm problems come in various types and difficulties. In this course, we will explore how to arrange parentheses to minimize an expression. This problem asks how efficiently we can calculate an expression through the placement of parentheses. Problem Description This is a problem of finding an arrangement of parentheses that minimizes an &hellip; <a href=\"https:\/\/atmokpo.com\/w\/35146\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Kotlin coding test course, finding the parenthesis placement to minimize the value&#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":[106],"tags":[],"class_list":["post-35146","post","type-post","status-publish","format-standard","hentry","category----en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Kotlin coding test course, finding the parenthesis placement to minimize the value - \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\/35146\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Kotlin coding test course, finding the parenthesis placement to minimize the value - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Coding tests and algorithm problems come in various types and difficulties. In this course, we will explore how to arrange parentheses to minimize an expression. This problem asks how efficiently we can calculate an expression through the placement of parentheses. Problem Description This is a problem of finding an arrangement of parentheses that minimizes an &hellip; \ub354 \ubcf4\uae30 &quot;Kotlin coding test course, finding the parenthesis placement to minimize the value&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/35146\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:36:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T12:40: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\/35146\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/35146\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Kotlin coding test course, finding the parenthesis placement to minimize the value\",\"datePublished\":\"2024-11-01T09:36:06+00:00\",\"dateModified\":\"2024-11-01T12:40:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/35146\/\"},\"wordCount\":425,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Kotlin coding test\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/35146\/\",\"url\":\"https:\/\/atmokpo.com\/w\/35146\/\",\"name\":\"Kotlin coding test course, finding the parenthesis placement to minimize the value - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:36:06+00:00\",\"dateModified\":\"2024-11-01T12:40:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/35146\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/35146\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/35146\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Kotlin coding test course, finding the parenthesis placement to minimize the value\"}]},{\"@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":"Kotlin coding test course, finding the parenthesis placement to minimize the value - \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\/35146\/","og_locale":"ko_KR","og_type":"article","og_title":"Kotlin coding test course, finding the parenthesis placement to minimize the value - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Coding tests and algorithm problems come in various types and difficulties. In this course, we will explore how to arrange parentheses to minimize an expression. This problem asks how efficiently we can calculate an expression through the placement of parentheses. Problem Description This is a problem of finding an arrangement of parentheses that minimizes an &hellip; \ub354 \ubcf4\uae30 \"Kotlin coding test course, finding the parenthesis placement to minimize the value\"","og_url":"https:\/\/atmokpo.com\/w\/35146\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:36:06+00:00","article_modified_time":"2024-11-01T12:40: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\/35146\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/35146\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Kotlin coding test course, finding the parenthesis placement to minimize the value","datePublished":"2024-11-01T09:36:06+00:00","dateModified":"2024-11-01T12:40:13+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/35146\/"},"wordCount":425,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Kotlin coding test"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/35146\/","url":"https:\/\/atmokpo.com\/w\/35146\/","name":"Kotlin coding test course, finding the parenthesis placement to minimize the value - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:36:06+00:00","dateModified":"2024-11-01T12:40:13+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/35146\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/35146\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/35146\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Kotlin coding test course, finding the parenthesis placement to minimize the value"}]},{"@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\/35146","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=35146"}],"version-history":[{"count":2,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/35146\/revisions"}],"predecessor-version":[{"id":38072,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/35146\/revisions\/38072"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=35146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=35146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=35146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}