Compute weighted sum of nested lists | Meta Interview Question