Every lone wolf int or repeated int is also in a hashtable {int -> {color, iterator in linked list}}

For every node encountered, we add it to the hashtable. If it is a new int, it’s appended to the linked list; if it turns from green to brown, then we remove it from linked list.

— one idea — O(N) two-pass. linkedHashMap
* any “new” element will be appended to a LinkedHashMap and painted green
* any “seen” element will be repainted brown in the same container.
* How to test for newness? Any examined element is tested by contains().
* 2nd scan to return 1st green.

— One idea — hash table + heap in fwd scan

use a hash table to hold payload objects, and progressively mark each payload green or brown

each payload consists of {color, index}. The key in the hash table is arr[index]

As we create a payload (to put into hash table), we also save its address in a min-heap, sorted on the index

After the scan, extract minimum from the heap, until we get a green element.

Many people ask how to make a child thread’s exception “bubble up” to the parent thread.

Background — A Runnable task is unsure how to handle its own exception. It wants to escalate to parent thread. Note parent has to block for the entire duration of the child thread (right after child’s start()), blocked either in wait() or some derivative of wait().

2) Runnable’s run() method can temporarily catch the exception, save the object in a global variable such as a blocking queue, and notifyAll(). Parent thread could check the global variable after getting notified. Any thread can monitor the gloabal.

If you don’t have to escalate to parent thread, then

3) setUncaughtExceptionHandler() – I think the handler method is called in the same exception thread — single-threaded. In the handler, you can give the task to a thread pool, so the exception thread can exit, but I don’t know how useful.

IRS is not transferable. IRS contract can be re-assigned in some cases, but the original 2 counter parties and the new party must all agree.

Both parties must scrutinize the other’s credit worthiness. Libor rate is for top-credit borrowers. If the floating-payer is lower, then the spread on Libor (or the fixed rate?) will reflect that – a.k.a. credit spread. Alternatively, the counter party (floating receiver) can demand collateral.

There’s no secondary market for IRS like there are in listed securities.

Q: Is there an IRS trading system?%%A: Most needed system might be a deal management system that tracks all our unexpired IRS contracts. Since each deal is bespoke, volume is not high. The basic entity in the system is known not as a position, but a deal. It’s treated like a trade as there are 2 accounts involved, and multiple settlement dates.

Q: Is IRS market regulated?A: Regulators set limits on total exposure. Participant’s quarterly balance sheets include these IR swaps. One big swap could push a company above the limit.

4) compiler coding question — is another tough interview type, be it take-home, onsite or webex.

With some exceptions (like easy coding questions), each of these skills is somewhat “ivory tower” i.e. removed from everyday reality, often unneeded in commercial projects. However these skills (including coding) are heavily tested by the smartest employers, the most respected companies including Google, Facebook, Microsoft… You and I may feel like the little boy in “emperor’s new dress”, but these smart guys can’t all be wrong.

I will again predict that coding questions would grow more popular as the logistic cost is driven down progressively.

Candidate screening is tough, time consuming and, to some extent, hit-and-miss. With all of these screening strategies, the new hire still can fail on TECHNICAL ground. Perhaps she/he lacks some practical skills — Code reading; debugging using logs; automation scripts; tool knowledge (like version control, text search/replace tools, build tools, and many linux commands)

Needless to say, new hire more often fail on non-technical ground like communication and attitude — another topic altogether.

In terms of real difficulty, toughest comp science problems revolve around algorithm and data structures, often without optimal solutions. Algo interview questions are the mainstay at big tech firms, but not on Wall St. Some say “Practice 6 months”. Second toughest would be coding questions —
* Often there’s too little time given
* Sometimes interviewer didn’t like our style but onsite coding tends to focus on substance rather than style.

In the US job market, people often ask “What do you specialize in?”. I think most non-managers in this industry, esp. the successful ones, do specialize in something. Whether you like it or not, you are often perceived that way.

Clearly, many professionals are jack of many trades (or a jack of few trades), and don’t have any real expertise, depth or insight. Depending on your view, this may not be a problem for them.