Skip to content

Instantly share code, notes, and snippets.

@feruxmax
Created March 2, 2021 10:59
Show Gist options
  • Select an option

  • Save feruxmax/48b5befe042a2bbea279c3addfc66e7c to your computer and use it in GitHub Desktop.

Select an option

Save feruxmax/48b5befe042a2bbea279c3addfc66e7c to your computer and use it in GitHub Desktop.
single-number
public class Solution {
public int SingleNumber(int[] nums) {
return nums.Aggregate((x, y) => x ^ y);
}
}
@ch1e
Copy link

ch1e commented Mar 2, 2021

Aggregate это вроде тоже что у нас reduce

@feruxmax
Copy link
Author

feruxmax commented Mar 2, 2021

2 ^ 2 ^ 1 = 1
xor это

@ch1e
Copy link

ch1e commented Mar 2, 2021

офигеть, я вообще про такое не знал
в свифте такая же есть оказывается
скинь почитать про эти штуки вообще, это битовые какиет операции?

@feruxmax
Copy link
Author

feruxmax commented Mar 2, 2021

https://en.wikipedia.org/wiki/Bitwise_operations_in_C это всё из проца торчит

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment