All problems
Write-Ahead Log Append
Problem
Append records to a write-ahead log with monotonic log sequence numbers.
existing is the current log of [lsn, key, value] entries. Each record in records is a [key, value] pair appended with the next LSN.
Return the full log after appending.
Hint
The LSN is one more than the number of entries already in the log.
Test cases
case 1
in: [[],[["a",1],["b",2]]]
expected: [[1,"a",1],[2,"b",2]]
case 2
in: [[[1,"x",0]],[["y",5]]]
expected: [[1,"x",0],[2,"y",5]]
case 3
in: [[],[]]
expected: []
case 4
in: [[[1,"a",1],[2,"b",2]],[["c",3]]]
expected: [[1,"a",1],[2,"b",2],[3,"c",3]]
Starter codePython
def wal_append(existing, records):
# Your code here
pass4 test cases · run your code against them in the editor