Worksheet range sum
A finance team exports a worksheet as a rectangular grid of whole numbers, where sheet[r][c] holds the value in row r and column c counting from zero. Ranges arrive as text in worksheet notation, for example B2:C3. A reference is one uppercase letter from A to Z naming the column, where A is column 0, followed by a row number counting from 1, so B2 means sheet[1][1]. The two references name opposite corners of a rectangle, but they can arrive in either order and either corner can come first, so C3:A1 and A3:C1 cover the same block as A1:C3. Return the sum of every value inside that rectangle, both corners included. Every reference lands inside the sheet.
sheet_range_total(sheet: list[list[int]], cell_range: str) → int[[[1,2,3,4],[5,6,7,8],[9,10,11,12]],"B2:C3"]out34[[[1,2,3,4],[5,6,7,8],[9,10,11,12]],"C3:A1"]out54[[[1,2,3,4],[5,6,7,8],[9,10,11,12]],"D1:D1"]out4State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[[1,2,3,4],[5,6,7,8],[9,10,11,12]],"B2:C3"]34not run yetsample[[[1,2,3,4],[5,6,7,8],[9,10,11,12]],"C3:A1"]54not run yetsample[[[1,2,3,4],[5,6,7,8],[9,10,11,12]],"D1:D1"]4not run yetsample