MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / title_to_number

Function title_to_number

171_title_to_number.rs:9–15  ·  view source on GitHub ↗

171 https://leetcode-cn.com/problems/excel-sheet-column-number/submissions/ "FXSHRXW" 2147483647

(column_title: String)

Source from the content-addressed store, hash-verified

7// 171 https://leetcode-cn.com/problems/excel-sheet-column-number/submissions/
8// "FXSHRXW" 2147483647
9pub fn title_to_number(column_title: String) -> i32 {
10 let mut sum = 0;
11 for (i, c) in column_title.chars().rev().enumerate() {
12 sum += 26_i32.pow(i as u32) * (c as i32 - 64)
13 };
14 sum
15}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected