<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Find missing element in an array.</title><link>https://community.appian.com/discussions/f/new-to-appian/28743/find-missing-element-in-an-array</link><description>Given an array of size N-1 such that it only contains distinct integers in the range of 1 to N. Find the missing element. 
 Example 1: 
 Input: N = 5 A[] = {1,2,3,5} Output: 4</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Find missing element in an array.</title><link>https://community.appian.com/thread/113121?ContentTypeID=1</link><pubDate>Mon, 22 May 2023 17:00:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:db0fd482-03ef-4b9b-8c4d-13c7035f72ac</guid><dc:creator>ankitr851905</dc:creator><description>&lt;p&gt;a!localVariables(&lt;br /&gt; local!number: { 1, 2, 3,4,5,7},&lt;br /&gt; local!n: length(local!number) ,&lt;br /&gt; ((local!n +1) *(local!n+2))/2 - sum(local!number),&lt;br /&gt; &lt;br /&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find missing element in an array.</title><link>https://community.appian.com/thread/113104?ContentTypeID=1</link><pubDate>Mon, 22 May 2023 13:23:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d427c6e5-d995-4edb-8f2c-e7efdfbb5b39</guid><dc:creator>davel001150</dc:creator><description>&lt;p&gt;I&amp;#39;d say this is the best approach except that I would go by length of the array +1, rather than by max value.&amp;nbsp; That eliminates the possibility of tripping up on first value or last value.&amp;nbsp; But I was totally about to bust out a!forEach.&lt;/p&gt;
&lt;p&gt;Plus I never knew that 1 + enumerate(n) worked; I always did enumerate(n) +1.&amp;nbsp; Still trying to decide which is more readable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find missing element in an array.</title><link>https://community.appian.com/thread/113098?ContentTypeID=1</link><pubDate>Mon, 22 May 2023 12:49:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f01061fb-8e2c-445c-a5ee-3df8fbf278c6</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Just swap max(local!list) with your actual maximum number - try this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!maxNumber: 6,
  local!list: {1, 2, 3, 4, 5},
  difference(1 + enumerate(local!maxNumber), local!list)
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find missing element in an array.</title><link>https://community.appian.com/thread/113071?ContentTypeID=1</link><pubDate>Mon, 22 May 2023 04:17:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d7dcec8c-4995-47ee-b08f-5dfea6f86d6c</guid><dc:creator>Amaan Shekh</dc:creator><description>&lt;p&gt;this code will not work for&amp;nbsp;{1,2,3,4,5} where&amp;nbsp; N = 6&amp;nbsp; or for similar cases&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find missing element in an array.</title><link>https://community.appian.com/thread/113070?ContentTypeID=1</link><pubDate>Mon, 22 May 2023 04:10:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:327a919d-0200-42f4-b7a6-b14466b6ded8</guid><dc:creator>Amaan Shekh</dc:creator><description>&lt;p&gt;alternate approach -&amp;gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!list: { 1, 2, 3, 4, 5, 6, 9, 8, 10, 11 },
  local!n: length(local!list) + 1,
  (local!n * (local!n + 1)) / 2 - sum(local!list)
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Find missing element in an array.</title><link>https://community.appian.com/thread/113069?ContentTypeID=1</link><pubDate>Sun, 21 May 2023 12:23:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c2674e7d-2caa-421b-95bb-0c80dcce8063</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!list: {1,2,3,5},
  difference(1 + enumerate(max(local!list)), local!list)
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>