Skip to content

Instantly share code, notes, and snippets.

@neo125874
Created July 22, 2016 08:17
Show Gist options
  • Save neo125874/ab95277406ef90cd6b82820319a5e302 to your computer and use it in GitHub Desktop.
Save neo125874/ab95277406ef90cd6b82820319a5e302 to your computer and use it in GitHub Desktop.
Codility Lesson 3-3 Time Complexity
using System;
// you can also use other imports, for example:
// using System.Collections.Generic;
// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");
class Solution {
public int solution(int[] A) {
double sum = 0;
double length = (double)A.Length;
for (int i = 0; i < length; i++)
sum += A[i];
var supposedSum = (length + 1) * ((double)(length + 2) / 2);
return (int)(supposedSum - sum);
// write your code in C# 6.0 with .NET 4.5 (Mono)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment