Simple backward looping with C#
Intuition\nThought about how we can minimize the amount of computation.\n\n# Approach\nLoop backward. \n\n1. In case of 9, assign 0. That means we need to incre
# Intuition\nThought about how we can minimize the amount of computation.\n\n# Approach\nLoop backward. \n\n1. In case of 9, assign 0. That means we need to increment next digit.\n2. The others increment and return the digits. \n3. If the loop has been finished, that means, it requres additional digit. add it and return it.\n\nOnly the 3 cases requires additional Memory space and breaks before reach N.\n\n# Complexity\n- Time complexity:\nO(2N) = O(N).\nNOTE: I don\'t know the internal of Concat method. So that my guess.\n\n- Space complexity:\nO(N): Probably, Linq might create a new List or equivalent.\n\n# Code\n```\npublic class Solution {\n    public int[] PlusOne(int[] digits) {\n       for(int i = digits.Length - 1; i >= 0; i--) {\n           if (digits[i] == 9) {\n               digits[i] = 0;\n           } else {\n               digits[i]++;\n               return digits;\n           }\n       } \n       int[] firstOne = new int[] { 1 };\n       return firstOne.Concat(digits).ToArray();\n    }\n}\n```
['C#']