Find the elements that appear only onceReturn the first recurring character in a stringDetermine whether any...
What is the word for reserving something for yourself before others do?
US citizen flying to France today and my passport expires in less than 2 months
What would happen to a modern skyscraper if it rains micro blackholes?
Hiring someone is unethical to Kantians because you're treating them as a means?
Today is the Center
Compress a signal by storing signal diff instead of actual samples - is there such a thing?
Important Resources for Dark Age Civilizations?
a relationship between local compactness and closure
What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)
The Clique vs. Independent Set Problem
Modeling an IP Address
Why doesn't H₄O²⁺ exist?
I'm planning on buying a laser printer but concerned about the life cycle of toner in the machine
What does "Puller Prush Person" mean?
How can bays and straits be determined in a procedurally generated map?
How can I make a cone from a cube and view the cube with different angles?
Is it important to consider tone, melody, and musical form while writing a song?
Can a Warlock become Neutral Good?
Can I make popcorn with any corn?
Why, historically, did Gödel think CH was false?
Schoenfled Residua test shows proportionality hazard assumptions holds but Kaplan-Meier plots intersect
Is it legal for company to use my work email to pretend I still work there?
The use of multiple foreign keys on same column in SQL Server
How can I make my BBEG immortal short of making them a Lich or Vampire?
Find the elements that appear only once
Return the first recurring character in a stringDetermine whether any permutation of a string is a palindromeArithmetic sequence in arrayGiven an unsorted integer array, find the first missing positive integerReturn the indices of the two numbers such that they add up to a specific targetFunction to find the shortest word in an array, where not every element is a stringGiven a sorted array nums, remove the duplicates in-placeFind the repeated elements in a listCount duplicates in a JavaScript arrayFind the smallest positive number missing from an unsorted arrayFirst missing positive integer in linear time and constant spaceFind index of the nearest larger number of a number
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
$begingroup$
The task:
Given an array of integers in which two elements appear exactly once
and all other elements appear exactly twice, find the two elements
that appear only once.
For example, given the array [2, 4, 6, 8, 10, 2, 6, 10], return 4 and
8. The order does not matter.
Follow-up: Can you do this in linear time and constant space?
const lst = [2, 4, 6, 8, 10, 2, 6, 10];
My functional solution
const findUnique = lst => lst
.sort((a,b) => a - b)
.filter((x, i) => lst[i-1] !== x && lst[i+1] !== x);
console.log(findUnique(lst));
My imperative solution:
function findUnique2(lst) {
const res = [];
const map = new Map();
lst.forEach(x => map.set(x, map.get(x) === undefined));
map.forEach((val, key) => {
if(val) { res.push(key); }
});
return res;
}
console.log(findUnique2(lst));
I think the imperative solution is in linear time but not constant space. How would you do it with constant space?
javascript algorithm programming-challenge functional-programming
$endgroup$
add a comment |
$begingroup$
The task:
Given an array of integers in which two elements appear exactly once
and all other elements appear exactly twice, find the two elements
that appear only once.
For example, given the array [2, 4, 6, 8, 10, 2, 6, 10], return 4 and
8. The order does not matter.
Follow-up: Can you do this in linear time and constant space?
const lst = [2, 4, 6, 8, 10, 2, 6, 10];
My functional solution
const findUnique = lst => lst
.sort((a,b) => a - b)
.filter((x, i) => lst[i-1] !== x && lst[i+1] !== x);
console.log(findUnique(lst));
My imperative solution:
function findUnique2(lst) {
const res = [];
const map = new Map();
lst.forEach(x => map.set(x, map.get(x) === undefined));
map.forEach((val, key) => {
if(val) { res.push(key); }
});
return res;
}
console.log(findUnique2(lst));
I think the imperative solution is in linear time but not constant space. How would you do it with constant space?
javascript algorithm programming-challenge functional-programming
$endgroup$
1
$begingroup$
order does not matter
order of inputs or order of results? The example shows exactly one deviation from monotonicity. (My guess: both.)
$endgroup$
– greybeard
Mar 30 at 10:10
add a comment |
$begingroup$
The task:
Given an array of integers in which two elements appear exactly once
and all other elements appear exactly twice, find the two elements
that appear only once.
For example, given the array [2, 4, 6, 8, 10, 2, 6, 10], return 4 and
8. The order does not matter.
Follow-up: Can you do this in linear time and constant space?
const lst = [2, 4, 6, 8, 10, 2, 6, 10];
My functional solution
const findUnique = lst => lst
.sort((a,b) => a - b)
.filter((x, i) => lst[i-1] !== x && lst[i+1] !== x);
console.log(findUnique(lst));
My imperative solution:
function findUnique2(lst) {
const res = [];
const map = new Map();
lst.forEach(x => map.set(x, map.get(x) === undefined));
map.forEach((val, key) => {
if(val) { res.push(key); }
});
return res;
}
console.log(findUnique2(lst));
I think the imperative solution is in linear time but not constant space. How would you do it with constant space?
javascript algorithm programming-challenge functional-programming
$endgroup$
The task:
Given an array of integers in which two elements appear exactly once
and all other elements appear exactly twice, find the two elements
that appear only once.
For example, given the array [2, 4, 6, 8, 10, 2, 6, 10], return 4 and
8. The order does not matter.
Follow-up: Can you do this in linear time and constant space?
const lst = [2, 4, 6, 8, 10, 2, 6, 10];
My functional solution
const findUnique = lst => lst
.sort((a,b) => a - b)
.filter((x, i) => lst[i-1] !== x && lst[i+1] !== x);
console.log(findUnique(lst));
My imperative solution:
function findUnique2(lst) {
const res = [];
const map = new Map();
lst.forEach(x => map.set(x, map.get(x) === undefined));
map.forEach((val, key) => {
if(val) { res.push(key); }
});
return res;
}
console.log(findUnique2(lst));
I think the imperative solution is in linear time but not constant space. How would you do it with constant space?
javascript algorithm programming-challenge functional-programming
javascript algorithm programming-challenge functional-programming
edited Mar 29 at 13:25
thadeuszlay
asked Mar 29 at 11:02
thadeuszlaythadeuszlay
796316
796316
1
$begingroup$
order does not matter
order of inputs or order of results? The example shows exactly one deviation from monotonicity. (My guess: both.)
$endgroup$
– greybeard
Mar 30 at 10:10
add a comment |
1
$begingroup$
order does not matter
order of inputs or order of results? The example shows exactly one deviation from monotonicity. (My guess: both.)
$endgroup$
– greybeard
Mar 30 at 10:10
1
1
$begingroup$
order does not matter
order of inputs or order of results? The example shows exactly one deviation from monotonicity. (My guess: both.)$endgroup$
– greybeard
Mar 30 at 10:10
$begingroup$
order does not matter
order of inputs or order of results? The example shows exactly one deviation from monotonicity. (My guess: both.)$endgroup$
– greybeard
Mar 30 at 10:10
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
How would you do it with constant space?
- Reduce the input list with
^
, let's call this resultxor
xor
isa ^ b
, wherea
andb
are the numbers that appear only once- Any set bit appears in either
a
orb
but not both - Set
bit
to a single bit that is inxor
. For example ifxor
is6
, thenbit
could be2
, or it could be4
, whichever, doesn't matter - Filter the input list with
& bit
. Realize that the matched values will include eithera
orb
but not both, thanks to our observation earlier. The filtered list will also include 0 or more duplicate pairs that may have matched. - Reduce the filtered list with
^
, let's call this resulta
. The value ofb
isxor ^ a
.
Something like this:
function findUnique(lst) {
const xor = lst.reduce((x, e) => x ^ e);
var bit = 1;
while ((bit & xor) === 0) {
bit <<= 1;
}
const a = lst.filter(x => x & bit).reduce((x, e) => x ^ e);
return [a, xor ^ a];
}
$endgroup$
$begingroup$
@greybeard absent-mindedness! Good points, thanks.
$endgroup$
– janos
Mar 31 at 7:04
add a comment |
$begingroup$
Sorting is not needed. A Set may be a better data structure for the task.
const find2Unique2 = a => Array.from( a.reduce(
(once, x) => (once.delete(x) || once.add(x), once),
new Set()
))
console.log( find2Unique2( [2, 0, 6, 8, 10, 2, 6, 10] ) );
I"m not sure how to solve this in constant space. If you xor all of the terms together
arr.reduce( (xor,x) => xor ^ x, 0 )
Then result = a ^ b
, where a
and b
are your two unique terms. If you can figure out a
, then b = result ^ a
. Or you can find some other reduction, you'll have two equations and two unknowns, and an algebraic solution might be possible.
For example, xor of the negated array combines with positive xor to uniquely identify a and b if they are two bits wide:
xor = arr.reduce( (xor,x) => xor ^ x, 0 )
neg = arr.reduce( (xor,x) => xor ^ -x, 0 )
a b xor neg & 0xF (high bits omitted for clarity)
0 1 => 1 1111
0 10 => 10 1110
0 11 => 11 1101
1 10 => 11 1
1 11 => 10 10
10 11 => 1 11
But it doesn't work for larger values. You could do multiple passes, with each pass xor-ing a right-shifted version of elements that could possibly match (if the last two bytes are 11
and 10
, you can skip numbers that don't end in those bits).
I didn't implement this because it's pretty complicated and it doesn't seem like the right answer. But maybe it gives you an idea.
$endgroup$
2
$begingroup$
to solve this in constant space [xor all] terms together
right on track! Think about what the value (X) obtained means: every bit not set is the same in both unique values (a and b). A bit set is different in a and b: Every bit set in X tells a from b.
$endgroup$
– greybeard
Mar 30 at 6:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216468%2ffind-the-elements-that-appear-only-once%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
How would you do it with constant space?
- Reduce the input list with
^
, let's call this resultxor
xor
isa ^ b
, wherea
andb
are the numbers that appear only once- Any set bit appears in either
a
orb
but not both - Set
bit
to a single bit that is inxor
. For example ifxor
is6
, thenbit
could be2
, or it could be4
, whichever, doesn't matter - Filter the input list with
& bit
. Realize that the matched values will include eithera
orb
but not both, thanks to our observation earlier. The filtered list will also include 0 or more duplicate pairs that may have matched. - Reduce the filtered list with
^
, let's call this resulta
. The value ofb
isxor ^ a
.
Something like this:
function findUnique(lst) {
const xor = lst.reduce((x, e) => x ^ e);
var bit = 1;
while ((bit & xor) === 0) {
bit <<= 1;
}
const a = lst.filter(x => x & bit).reduce((x, e) => x ^ e);
return [a, xor ^ a];
}
$endgroup$
$begingroup$
@greybeard absent-mindedness! Good points, thanks.
$endgroup$
– janos
Mar 31 at 7:04
add a comment |
$begingroup$
How would you do it with constant space?
- Reduce the input list with
^
, let's call this resultxor
xor
isa ^ b
, wherea
andb
are the numbers that appear only once- Any set bit appears in either
a
orb
but not both - Set
bit
to a single bit that is inxor
. For example ifxor
is6
, thenbit
could be2
, or it could be4
, whichever, doesn't matter - Filter the input list with
& bit
. Realize that the matched values will include eithera
orb
but not both, thanks to our observation earlier. The filtered list will also include 0 or more duplicate pairs that may have matched. - Reduce the filtered list with
^
, let's call this resulta
. The value ofb
isxor ^ a
.
Something like this:
function findUnique(lst) {
const xor = lst.reduce((x, e) => x ^ e);
var bit = 1;
while ((bit & xor) === 0) {
bit <<= 1;
}
const a = lst.filter(x => x & bit).reduce((x, e) => x ^ e);
return [a, xor ^ a];
}
$endgroup$
$begingroup$
@greybeard absent-mindedness! Good points, thanks.
$endgroup$
– janos
Mar 31 at 7:04
add a comment |
$begingroup$
How would you do it with constant space?
- Reduce the input list with
^
, let's call this resultxor
xor
isa ^ b
, wherea
andb
are the numbers that appear only once- Any set bit appears in either
a
orb
but not both - Set
bit
to a single bit that is inxor
. For example ifxor
is6
, thenbit
could be2
, or it could be4
, whichever, doesn't matter - Filter the input list with
& bit
. Realize that the matched values will include eithera
orb
but not both, thanks to our observation earlier. The filtered list will also include 0 or more duplicate pairs that may have matched. - Reduce the filtered list with
^
, let's call this resulta
. The value ofb
isxor ^ a
.
Something like this:
function findUnique(lst) {
const xor = lst.reduce((x, e) => x ^ e);
var bit = 1;
while ((bit & xor) === 0) {
bit <<= 1;
}
const a = lst.filter(x => x & bit).reduce((x, e) => x ^ e);
return [a, xor ^ a];
}
$endgroup$
How would you do it with constant space?
- Reduce the input list with
^
, let's call this resultxor
xor
isa ^ b
, wherea
andb
are the numbers that appear only once- Any set bit appears in either
a
orb
but not both - Set
bit
to a single bit that is inxor
. For example ifxor
is6
, thenbit
could be2
, or it could be4
, whichever, doesn't matter - Filter the input list with
& bit
. Realize that the matched values will include eithera
orb
but not both, thanks to our observation earlier. The filtered list will also include 0 or more duplicate pairs that may have matched. - Reduce the filtered list with
^
, let's call this resulta
. The value ofb
isxor ^ a
.
Something like this:
function findUnique(lst) {
const xor = lst.reduce((x, e) => x ^ e);
var bit = 1;
while ((bit & xor) === 0) {
bit <<= 1;
}
const a = lst.filter(x => x & bit).reduce((x, e) => x ^ e);
return [a, xor ^ a];
}
edited Mar 31 at 7:03
answered Mar 30 at 21:53
janosjanos
99.4k12127351
99.4k12127351
$begingroup$
@greybeard absent-mindedness! Good points, thanks.
$endgroup$
– janos
Mar 31 at 7:04
add a comment |
$begingroup$
@greybeard absent-mindedness! Good points, thanks.
$endgroup$
– janos
Mar 31 at 7:04
$begingroup$
@greybeard absent-mindedness! Good points, thanks.
$endgroup$
– janos
Mar 31 at 7:04
$begingroup$
@greybeard absent-mindedness! Good points, thanks.
$endgroup$
– janos
Mar 31 at 7:04
add a comment |
$begingroup$
Sorting is not needed. A Set may be a better data structure for the task.
const find2Unique2 = a => Array.from( a.reduce(
(once, x) => (once.delete(x) || once.add(x), once),
new Set()
))
console.log( find2Unique2( [2, 0, 6, 8, 10, 2, 6, 10] ) );
I"m not sure how to solve this in constant space. If you xor all of the terms together
arr.reduce( (xor,x) => xor ^ x, 0 )
Then result = a ^ b
, where a
and b
are your two unique terms. If you can figure out a
, then b = result ^ a
. Or you can find some other reduction, you'll have two equations and two unknowns, and an algebraic solution might be possible.
For example, xor of the negated array combines with positive xor to uniquely identify a and b if they are two bits wide:
xor = arr.reduce( (xor,x) => xor ^ x, 0 )
neg = arr.reduce( (xor,x) => xor ^ -x, 0 )
a b xor neg & 0xF (high bits omitted for clarity)
0 1 => 1 1111
0 10 => 10 1110
0 11 => 11 1101
1 10 => 11 1
1 11 => 10 10
10 11 => 1 11
But it doesn't work for larger values. You could do multiple passes, with each pass xor-ing a right-shifted version of elements that could possibly match (if the last two bytes are 11
and 10
, you can skip numbers that don't end in those bits).
I didn't implement this because it's pretty complicated and it doesn't seem like the right answer. But maybe it gives you an idea.
$endgroup$
2
$begingroup$
to solve this in constant space [xor all] terms together
right on track! Think about what the value (X) obtained means: every bit not set is the same in both unique values (a and b). A bit set is different in a and b: Every bit set in X tells a from b.
$endgroup$
– greybeard
Mar 30 at 6:22
add a comment |
$begingroup$
Sorting is not needed. A Set may be a better data structure for the task.
const find2Unique2 = a => Array.from( a.reduce(
(once, x) => (once.delete(x) || once.add(x), once),
new Set()
))
console.log( find2Unique2( [2, 0, 6, 8, 10, 2, 6, 10] ) );
I"m not sure how to solve this in constant space. If you xor all of the terms together
arr.reduce( (xor,x) => xor ^ x, 0 )
Then result = a ^ b
, where a
and b
are your two unique terms. If you can figure out a
, then b = result ^ a
. Or you can find some other reduction, you'll have two equations and two unknowns, and an algebraic solution might be possible.
For example, xor of the negated array combines with positive xor to uniquely identify a and b if they are two bits wide:
xor = arr.reduce( (xor,x) => xor ^ x, 0 )
neg = arr.reduce( (xor,x) => xor ^ -x, 0 )
a b xor neg & 0xF (high bits omitted for clarity)
0 1 => 1 1111
0 10 => 10 1110
0 11 => 11 1101
1 10 => 11 1
1 11 => 10 10
10 11 => 1 11
But it doesn't work for larger values. You could do multiple passes, with each pass xor-ing a right-shifted version of elements that could possibly match (if the last two bytes are 11
and 10
, you can skip numbers that don't end in those bits).
I didn't implement this because it's pretty complicated and it doesn't seem like the right answer. But maybe it gives you an idea.
$endgroup$
2
$begingroup$
to solve this in constant space [xor all] terms together
right on track! Think about what the value (X) obtained means: every bit not set is the same in both unique values (a and b). A bit set is different in a and b: Every bit set in X tells a from b.
$endgroup$
– greybeard
Mar 30 at 6:22
add a comment |
$begingroup$
Sorting is not needed. A Set may be a better data structure for the task.
const find2Unique2 = a => Array.from( a.reduce(
(once, x) => (once.delete(x) || once.add(x), once),
new Set()
))
console.log( find2Unique2( [2, 0, 6, 8, 10, 2, 6, 10] ) );
I"m not sure how to solve this in constant space. If you xor all of the terms together
arr.reduce( (xor,x) => xor ^ x, 0 )
Then result = a ^ b
, where a
and b
are your two unique terms. If you can figure out a
, then b = result ^ a
. Or you can find some other reduction, you'll have two equations and two unknowns, and an algebraic solution might be possible.
For example, xor of the negated array combines with positive xor to uniquely identify a and b if they are two bits wide:
xor = arr.reduce( (xor,x) => xor ^ x, 0 )
neg = arr.reduce( (xor,x) => xor ^ -x, 0 )
a b xor neg & 0xF (high bits omitted for clarity)
0 1 => 1 1111
0 10 => 10 1110
0 11 => 11 1101
1 10 => 11 1
1 11 => 10 10
10 11 => 1 11
But it doesn't work for larger values. You could do multiple passes, with each pass xor-ing a right-shifted version of elements that could possibly match (if the last two bytes are 11
and 10
, you can skip numbers that don't end in those bits).
I didn't implement this because it's pretty complicated and it doesn't seem like the right answer. But maybe it gives you an idea.
$endgroup$
Sorting is not needed. A Set may be a better data structure for the task.
const find2Unique2 = a => Array.from( a.reduce(
(once, x) => (once.delete(x) || once.add(x), once),
new Set()
))
console.log( find2Unique2( [2, 0, 6, 8, 10, 2, 6, 10] ) );
I"m not sure how to solve this in constant space. If you xor all of the terms together
arr.reduce( (xor,x) => xor ^ x, 0 )
Then result = a ^ b
, where a
and b
are your two unique terms. If you can figure out a
, then b = result ^ a
. Or you can find some other reduction, you'll have two equations and two unknowns, and an algebraic solution might be possible.
For example, xor of the negated array combines with positive xor to uniquely identify a and b if they are two bits wide:
xor = arr.reduce( (xor,x) => xor ^ x, 0 )
neg = arr.reduce( (xor,x) => xor ^ -x, 0 )
a b xor neg & 0xF (high bits omitted for clarity)
0 1 => 1 1111
0 10 => 10 1110
0 11 => 11 1101
1 10 => 11 1
1 11 => 10 10
10 11 => 1 11
But it doesn't work for larger values. You could do multiple passes, with each pass xor-ing a right-shifted version of elements that could possibly match (if the last two bytes are 11
and 10
, you can skip numbers that don't end in those bits).
I didn't implement this because it's pretty complicated and it doesn't seem like the right answer. But maybe it gives you an idea.
const find2Unique2 = a => Array.from( a.reduce(
(once, x) => (once.delete(x) || once.add(x), once),
new Set()
))
console.log( find2Unique2( [2, 0, 6, 8, 10, 2, 6, 10] ) );
const find2Unique2 = a => Array.from( a.reduce(
(once, x) => (once.delete(x) || once.add(x), once),
new Set()
))
console.log( find2Unique2( [2, 0, 6, 8, 10, 2, 6, 10] ) );
answered Mar 29 at 20:57
Oh My GoodnessOh My Goodness
2,192315
2,192315
2
$begingroup$
to solve this in constant space [xor all] terms together
right on track! Think about what the value (X) obtained means: every bit not set is the same in both unique values (a and b). A bit set is different in a and b: Every bit set in X tells a from b.
$endgroup$
– greybeard
Mar 30 at 6:22
add a comment |
2
$begingroup$
to solve this in constant space [xor all] terms together
right on track! Think about what the value (X) obtained means: every bit not set is the same in both unique values (a and b). A bit set is different in a and b: Every bit set in X tells a from b.
$endgroup$
– greybeard
Mar 30 at 6:22
2
2
$begingroup$
to solve this in constant space [xor all] terms together
right on track! Think about what the value (X) obtained means: every bit not set is the same in both unique values (a and b). A bit set is different in a and b: Every bit set in X tells a from b.$endgroup$
– greybeard
Mar 30 at 6:22
$begingroup$
to solve this in constant space [xor all] terms together
right on track! Think about what the value (X) obtained means: every bit not set is the same in both unique values (a and b). A bit set is different in a and b: Every bit set in X tells a from b.$endgroup$
– greybeard
Mar 30 at 6:22
add a comment |
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216468%2ffind-the-elements-that-appear-only-once%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
order does not matter
order of inputs or order of results? The example shows exactly one deviation from monotonicity. (My guess: both.)$endgroup$
– greybeard
Mar 30 at 10:10