{"id":41,"date":"2019-02-06T04:29:59","date_gmt":"2019-02-06T04:29:59","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/coding\/?p=41"},"modified":"2019-02-06T04:29:59","modified_gmt":"2019-02-06T04:29:59","slug":"question-5-find-largest-sub-array","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/","title":{"rendered":"Question 5 &#8211; Find Largest Sub-array"},"content":{"rendered":"<h4>Question 5<\/h4>\n<p>You are given an unsorted array of integers. You\u00a0 need to find the largest sub-array formed by consecutive numbers. The sub-array should only contain unique values. For example<\/p>\n<p><strong>Input:\u00a0<\/strong>{2, 7, 2, 1, 4, 3, 5, 0}<\/p>\n<p><strong>Output:\u00a0<\/strong>The largest subarray is from index 2 to 7<\/p>\n<p>The sub-array is {2, 1, 4, 3, 5}<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Solution\u00a0<\/strong><\/h4>\n<p>The approach is to iterate through the array. Then we keep track of the largest sub-array seen so far. We also make sure that the integers in the sub-array is consecutive.<\/p>\n<p>For the sub-array elements to be consecutive, then:<\/p>\n<ul>\n<li>the difference between the largest and smallest element must be equal to the length of the sub-array minus one<\/li>\n<li>we check the the elements are unique track tracking the already visited element in another array.<\/li>\n<\/ul>\n<p>The Java code is given below:<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\">\/*<\/span>\r\n<span style=\"color: #888888;\"> * Find the largest consecutive sub-array<\/span>\r\n<span style=\"color: #888888;\"> * Written by: Kindson The Genius<\/span>\r\n<span style=\"color: #888888;\"> *\/<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">LargestSubarray<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n\t<span style=\"color: #888888;\">\/\/helper function to check if sub-array is consecutive<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">isConsecutive<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> A<span style=\"color: #333333;\">[],<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> i<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> j<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> min<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> max<span style=\"color: #333333;\">)<\/span> \r\n\t<span style=\"color: #333333;\">{<\/span>\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>max <span style=\"color: #333333;\">-<\/span> min <span style=\"color: #333333;\">!=<\/span> j <span style=\"color: #333333;\">-<\/span> i<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #888888;\">\/\/track the visited elements<\/span>\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">boolean<\/span> visited<span style=\"color: #333333;\">[]<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span><span style=\"color: #333333;\">[<\/span>j <span style=\"color: #333333;\">-<\/span> i <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">];<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">for<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> k <span style=\"color: #333333;\">=<\/span> i<span style=\"color: #333333;\">;<\/span> k <span style=\"color: #333333;\">&lt;=<\/span> j<span style=\"color: #333333;\">;<\/span> k<span style=\"color: #333333;\">++)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\t<span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>visited<span style=\"color: #333333;\">[<\/span>A<span style=\"color: #333333;\">[<\/span>k<span style=\"color: #333333;\">]<\/span> <span style=\"color: #333333;\">-<\/span> min<span style=\"color: #333333;\">])<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\t\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t\t\r\n\t\t\tvisited<span style=\"color: #333333;\">[<\/span>A<span style=\"color: #333333;\">[<\/span>k<span style=\"color: #333333;\">]<\/span> <span style=\"color: #333333;\">-<\/span> min<span style=\"color: #333333;\">]<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span>\t\t\r\n\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n\t\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">findMaxSubarray<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span><span style=\"color: #333333;\">[]<\/span> A<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> len <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> start <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> end <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #888888;\">\/\/Loop through all the elements of the array<\/span>\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">for<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> i <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span> i <span style=\"color: #333333;\">&lt;<\/span> A<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">length<\/span> <span style=\"color: #333333;\">-<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">;<\/span> i<span style=\"color: #333333;\">++)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> min_val <span style=\"color: #333333;\">=<\/span> A<span style=\"color: #333333;\">[<\/span>i<span style=\"color: #333333;\">];<\/span>\r\n\t\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> max_val <span style=\"color: #333333;\">=<\/span> A<span style=\"color: #333333;\">[<\/span>i<span style=\"color: #333333;\">];<\/span>\r\n\t\t\t\r\n\t\t\t<span style=\"color: #888888;\">\/\/Loop through the current sub-array<\/span>\r\n\t\t\t<span style=\"color: #008800; font-weight: bold;\">for<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> j <span style=\"color: #333333;\">=<\/span> i<span style=\"color: #333333;\">;<\/span> j <span style=\"color: #333333;\">&lt;<\/span> A<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">length<\/span><span style=\"color: #333333;\">;<\/span> j<span style=\"color: #333333;\">++)<\/span> \r\n\t\t\t<span style=\"color: #333333;\">{<\/span>\r\n\t\t\t\tmin_val <span style=\"color: #333333;\">=<\/span> Math<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">min<\/span><span style=\"color: #333333;\">(<\/span>min_val<span style=\"color: #333333;\">,<\/span> A<span style=\"color: #333333;\">[<\/span>j<span style=\"color: #333333;\">]);<\/span>\r\n\t\t\t\tmax_val <span style=\"color: #333333;\">=<\/span> Math<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">max<\/span><span style=\"color: #333333;\">(<\/span>max_val<span style=\"color: #333333;\">,<\/span> A<span style=\"color: #333333;\">[<\/span>j<span style=\"color: #333333;\">]);<\/span>\r\n\t\t\t\t\r\n\t\t\t\t<span style=\"color: #888888;\">\/\/check the the elements are consecutive<\/span>\r\n\t\t\t\t<span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>isConsecutive<span style=\"color: #333333;\">(<\/span>A<span style=\"color: #333333;\">,<\/span> i<span style=\"color: #333333;\">,<\/span> j<span style=\"color: #333333;\">,<\/span> min_val<span style=\"color: #333333;\">,<\/span> max_val<span style=\"color: #333333;\">))<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\t\t\t<span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>len <span style=\"color: #333333;\">&lt;<\/span> max_val <span style=\"color: #333333;\">-<\/span> min_val <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\t\t\t\tlen <span style=\"color: #333333;\">=<\/span> max_val <span style=\"color: #333333;\">-<\/span> min_val <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\t\t\t\tstart <span style=\"color: #333333;\">=<\/span> i<span style=\"color: #333333;\">;<\/span>\r\n\t\t\t\t\t\tend <span style=\"color: #333333;\">=<\/span> j<span style=\"color: #333333;\">;<\/span>\r\n\t\t\t\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t\t\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t\t<span style=\"color: #333333;\">}<\/span>\r\n\t\t\r\n\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"The largest subarray is from index \"<\/span>\r\n\t\t\t\t<span style=\"color: #333333;\">+<\/span> start <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">\" to \"<\/span> <span style=\"color: #333333;\">+<\/span> end<span style=\"color: #333333;\">);<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n\t\r\n\t<span style=\"color: #888888;\">\/\/Test the program<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> args<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span><span style=\"color: #333333;\">[]<\/span> A <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">{<\/span><span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">7<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">4<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">3<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">};<\/span>\r\n\t\tfindMaxSubarray<span style=\"color: #333333;\">(<\/span>A<span style=\"color: #333333;\">);<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Question 5 You are given an unsorted array of integers. You\u00a0 need to find the largest sub-array formed by consecutive numbers. The sub-array should only &hellip; <\/p>\n","protected":false},"author":395,"featured_media":42,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,2,3],"tags":[18],"class_list":["post-41","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-array","category-coding-challenge","category-java","tag-largest-sub-array"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Question 5 - Find Largest Sub-array - Coding Challenge<\/title>\n<meta name=\"description\" content=\"Given an array of integers which are unsorted, you need to find the largest sub-array made up of consecutive integers. The elements must be unique\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Question 5 - Find Largest Sub-array - Coding Challenge\" \/>\n<meta property=\"og:description\" content=\"Given an array of integers which are unsorted, you need to find the largest sub-array made up of consecutive integers. The elements must be unique\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/\" \/>\n<meta property=\"og:site_name\" content=\"Coding Challenge\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-06T04:29:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/coding\/wp-content\/uploads\/sites\/4\/2019\/02\/Largest-Sub-array.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"927\" \/>\n\t<meta property=\"og:image:height\" content=\"496\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"headline\":\"Question 5 &#8211; Find Largest Sub-array\",\"datePublished\":\"2019-02-06T04:29:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/\"},\"wordCount\":129,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/wp-content\\\/uploads\\\/sites\\\/4\\\/2019\\\/02\\\/Largest-Sub-array.jpg\",\"keywords\":[\"Largest Sub-array\"],\"articleSection\":[\"Array\",\"Coding Challenge\",\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/\",\"name\":\"Question 5 - Find Largest Sub-array - Coding Challenge\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/wp-content\\\/uploads\\\/sites\\\/4\\\/2019\\\/02\\\/Largest-Sub-array.jpg\",\"datePublished\":\"2019-02-06T04:29:59+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"description\":\"Given an array of integers which are unsorted, you need to find the largest sub-array made up of consecutive integers. The elements must be unique\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/wp-content\\\/uploads\\\/sites\\\/4\\\/2019\\\/02\\\/Largest-Sub-array.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/wp-content\\\/uploads\\\/sites\\\/4\\\/2019\\\/02\\\/Largest-Sub-array.jpg\",\"width\":927,\"height\":496,\"caption\":\"Find the largest sub-array\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/question-5-find-largest-sub-array\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Question 5 &#8211; Find Largest Sub-array\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/\",\"name\":\"Coding Challenge\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/coding\\\/author\\\/kindsonthegenius-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Question 5 - Find Largest Sub-array - Coding Challenge","description":"Given an array of integers which are unsorted, you need to find the largest sub-array made up of consecutive integers. The elements must be unique","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:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/","og_locale":"en_US","og_type":"article","og_title":"Question 5 - Find Largest Sub-array - Coding Challenge","og_description":"Given an array of integers which are unsorted, you need to find the largest sub-array made up of consecutive integers. The elements must be unique","og_url":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/","og_site_name":"Coding Challenge","article_published_time":"2019-02-06T04:29:59+00:00","og_image":[{"width":927,"height":496,"url":"https:\/\/www.kindsonthegenius.com\/coding\/wp-content\/uploads\/sites\/4\/2019\/02\/Largest-Sub-array.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/coding\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"headline":"Question 5 &#8211; Find Largest Sub-array","datePublished":"2019-02-06T04:29:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/"},"wordCount":129,"commentCount":0,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/coding\/wp-content\/uploads\/sites\/4\/2019\/02\/Largest-Sub-array.jpg","keywords":["Largest Sub-array"],"articleSection":["Array","Coding Challenge","Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/","url":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/","name":"Question 5 - Find Largest Sub-array - Coding Challenge","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/coding\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/coding\/wp-content\/uploads\/sites\/4\/2019\/02\/Largest-Sub-array.jpg","datePublished":"2019-02-06T04:29:59+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/coding\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"description":"Given an array of integers which are unsorted, you need to find the largest sub-array made up of consecutive integers. The elements must be unique","breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/coding\/wp-content\/uploads\/sites\/4\/2019\/02\/Largest-Sub-array.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/coding\/wp-content\/uploads\/sites\/4\/2019\/02\/Largest-Sub-array.jpg","width":927,"height":496,"caption":"Find the largest sub-array"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/coding\/question-5-find-largest-sub-array\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/coding\/"},{"@type":"ListItem","position":2,"name":"Question 5 &#8211; Find Largest Sub-array"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/coding\/#website","url":"https:\/\/www.kindsonthegenius.com\/coding\/","name":"Coding Challenge","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/coding\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/coding\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/coding\/author\/kindsonthegenius-2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/users\/395"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":1,"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":43,"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/posts\/41\/revisions\/43"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/media\/42"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/coding\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}