
using System;
using System.Collections.Generic;
// 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 N)
{
// write your code in C# 6.0 with .NET 4.5 (Mono)
string binaryN = Convert.ToString(N, 2);
List<int> pos = new List<int>();
for (int i = 0; i < binaryN.Length; i++)
{
if (binaryN[i]=='1')
{
pos.Add(i);
}
}
int ans = 0;
for (int i = 1; i < pos.Count; i++)
{
int r = pos[i] - pos[i - 1] - 1;
if (r > ans)
{
ans = r;
}
}
return ans;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
// 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, int K) {
// write your code in C# 6.0 with .NET 4.5 (Mono)
if (A.Length == 0)
{
return A;
}
Queue<int> que = new Queue<int>(A.Reverse());
for (int i = 0; i < K; i++)
{
int picked = que.Dequeue();
que.Enqueue(picked);
}
return que.ToArray().Reverse().ToArray();
}
}
public void rotate(int[] arr, int k) {
int n = arr.length;
int pre = arr[0], cur = 0;
for (int i = 0; i < n; ++i) {
int to = (cur + k) % n;
int temp = arr[to];
arr[to] = pre;
pre = temp;
cur = to;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
class Solution {
public int solution(int[] A)
{
HashSet<int> hash = new HashSet<int>();
foreach (int i in A)
{
if (hash.Contains(i))
{
hash.Remove(i);
}
else
{
hash.Add(i);
}
}
return hash.First();
}
}
int solution(const std::vector<int>& A) {
int answer = 0;
for (int ai : A) {
answer ^= ai;
}
return answer;
}