C# || O(n) solution using for loop
Intuition\n Describe your first thoughts on how to solve this problem. \nThe main idea is to keep track of the minimum and the maximum difference while reading 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe main idea is to keep track of the minimum and the maximum difference while reading each element from index 0 to the end of the input array.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. declare two variables - **max** and **min**\n2. create a for loop that checks for two things - 1) if the current element is the lowest value or not 2) if the current element - **min** is greater than the existing **max** value.  Use the Math.Max() method to keep **max** as the greatest difference always.\n3. once the for loop completes, check if the **max** value is greater than 0.  If so, return the **max** value as is.  Otherwise, return -1.\n\nThe assumption for step 2 is that the **max** value can be a negative value which is why step 3 has a logic to check if **max** is a positive value or not.  \n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\npublic class Solution {\n    public int MaximumDifference(int[] nums) {\n        \n        var max = int.MinValue;\n        var min = int.MaxValue;\n        \n        for (int i = 0; i < nums.Length; i++)\n        {\n            min = Math.Min(nums[i], min); \n            max = Math.Max(max, nums[i] - min);\n        }\n        return max > 0? max : -1;\n    }\n}\n```
['C#']