<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mohamed Shawky</title>
    <description>The latest articles on DEV Community by Mohamed Shawky (@mo7ameds7awky).</description>
    <link>https://dev.to/mo7ameds7awky</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F843304%2F1145aefe-4300-429c-8087-311483f4d1f7.jpg</url>
      <title>DEV Community: Mohamed Shawky</title>
      <link>https://dev.to/mo7ameds7awky</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mo7ameds7awky"/>
    <language>en</language>
    <item>
      <title>Mini-Max Sum Problem</title>
      <dc:creator>Mohamed Shawky</dc:creator>
      <pubDate>Fri, 08 Apr 2022 01:27:20 +0000</pubDate>
      <link>https://dev.to/mo7ameds7awky/mini-max-sum-problem-d47</link>
      <guid>https://dev.to/mo7ameds7awky/mini-max-sum-problem-d47</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem statement&lt;/strong&gt;&lt;br&gt;
Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.&lt;/p&gt;

&lt;p&gt;Solution steps:&lt;/p&gt;

&lt;p&gt;I thought about the problem mathematically that the sum of the smallest number in a set is the minimum sum and the sum of the biggest numbers in a set is the maximum sum so:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Sorted the given array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get the minimum sum by the summation of the first four numbers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get the maximum sum by the summation of the last four numbers.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def miniMaxSum(arr):
    sorted_list = sorted(arr)
    min_sum = sorted_list[0] + sorted_list[1] + sorted_list[2] + sorted_list[3]
    max_sum = sorted_list[1] + sorted_list[2] + sorted_list[3] + sorted_list[4]
    print(str(min_sum) + " " + str(max_sum))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem is from Hackerrank website.&lt;br&gt;
The problem url: &lt;a href="https://www.hackerrank.com/challenges/mini-max-sum/problem"&gt;Mini-Max Sum&lt;/a&gt;&lt;/p&gt;

</description>
      <category>problemsolving</category>
      <category>python</category>
      <category>hackerrank</category>
    </item>
  </channel>
</rss>
