💠 "In the midst of chaos, there is also opportunity." - Sun Tzu
LinkedList<Integer> backward = new LinkedList<Integer>();
return reverseQueueRecursive(forward, backward);
}
// recursive helper method
static public LinkedList<Integer> reverseQueueRecursive(LinkedList<Integer> forward, LinkedList<Integer> backward) {
if (forward.peekLast() == null) {
return backward;
} else {
backward.add(forward.pollLast());
return reverseQueueRecursive(forward, backward);
}
}
Meanwhile, these lovely folks tweeted theirs!
This week’s problem:
Given an unsorted integer array arr and an integer n, return a pair of numbers (from arr) whose product is closest to n.
Example:
closestProduct([5,3,8,2,7], 42);
> [5, 8]
Cool things from around the internet
HHKB with pastel caps
Want to Remember the Notes You Take? Here’s Why You Need to Write Them By Hand
How a Uranium Hunter Sniffs Out Nuclear Weapons
The Chorus: by Anthony Bourdain
Joke
A backpacker walks into a bar. The bartender says, “Welcome! What are you drinking?”
The backpacker, weary from her journey, says, “Your finest pale ale, please.” The bartender tells her, “Sure thing.”
As he pours her a pint, he makes her an offer.
“Since you’re new here, I’ll offer you a gift I offer all of my first time customers. You may choose either this first pint of ale is free or instead you may pay for the beer and I will give you a piece of valuable advice.” The backpacker pondered before deciding.
“I’m intrigued by your offer. I will pay for my ale, now please share the valuable advice.” The bartender grinned, counting the cash she had given him, looked her in the eye and said, “You should’ve taken the free beer.”
Thanks for reading again, friends. Have a great week. Be safe, make good choices, and talk to your loved ones.
cassidoo