You are given a list of riders and a chronological list of Uber Share events. Each shared-ride event connects two riders. Two riders are connected if they have directly or indirectly shared rides through other riders.
Return the earliest timestamp when all riders become part of one connected shared-ride network. If all riders never become connected, return -1.
long earliestFullConnectivityTimestamp(List<String> riders, List<String> logs)
riders contains all possible riders.logs contains ride-sharing events sorted by timestamp in non-decreasing order."timestamp,rider1,rider2"."timestamp,Alice,Bob" means Alice shared a ride with Bob at that timestamp.long earliestFullConnectivityTimestampWithBlocks(List<String> riders, List<String> logs)
"timestamp,eventType,rider1,rider2".eventType is either "SHARE" or "BLOCK"."timestamp,SHARE,Alice,Bob" adds a connection between Alice and Bob."timestamp,BLOCK,Alice,Bob" removes the direct connection between Alice and Bob, if it exists.-1 if it never happens.riders.riders contains exactly one rider, return 0.1 ≤ riders.size() ≤ 100,0000 ≤ logs.size() ≤ 200,0001 ≤ rider.length() ≤ 500 ≤ timestamp ≤ 999,999,999,999null.1 ≤ riders.size() ≤ 2,0000 ≤ logs.size() ≤ 10,000"timestamp,eventType,rider1,rider2".eventType is either "SHARE" or "BLOCK".earliestFullConnectivityTimestamp(riders = ["Ava", "Ben", "Cara", "Dev"], logs = ["101,Ava,Ben", "105,Cara,Dev", "110,Ben,Cara"])
Output: 110
Explanation: At timestamp 110, the groups Ava-Ben and Cara-Dev become connected through Ben-Cara.
earliestFullConnectivityTimestamp(riders = ["Mia", "Noah", "Omar"], logs = ["200,Mia,Noah"])
Output: -1
Explanation: Omar never becomes connected with the other riders.
earliestFullConnectivityTimestamp(riders = ["Zara"], logs = [])
Output: 0
Explanation: A single rider is already fully connected.
earliestFullConnectivityTimestampWithBlocks(riders = ["A", "B", "C"], logs = ["10,SHARE,A,B", "20,SHARE,B,C"])
Output: 20
Explanation: At timestamp 20, all riders are connected through active share connections.
earliestFullConnectivityTimestampWithBlocks(riders = ["A", "B", "C"], logs = ["10,SHARE,A,B", "15,BLOCK,A,B", "20,SHARE,B,C", "25,SHARE,A,C"])
Output: 25
Explanation: The connection between A and B is removed at timestamp 15. All riders become connected only after A shares with C at timestamp 25.