MCPcopy Create free account
hub / github.com/EricPengShuai/Interview / stringToIntegerVector

Function stringToIntegerVector

memo/listnode.cpp:60–73  ·  view source on GitHub ↗

字符串输入转 vector:[1,2,3,4,5]

Source from the content-addressed store, hash-verified

58
59// 字符串输入转 vector:[1,2,3,4,5]
60vector<int> stringToIntegerVector(string input) {
61 vector<int> output;
62 trimLeftTrailingSpaces(input);
63 trimRightTrailingSpaces(input);
64 input = input.substr(1, input.length() - 2);
65 stringstream ss;
66 ss.str(input);
67 string item;
68 char delim = ',';
69 while (getline(ss, item, delim)) {
70 output.push_back(stoi(item));
71 }
72 return output;
73}
74
75
76// 注意构造链表的方式

Callers 1

stringToListNodeFunction · 0.85

Calls 3

trimLeftTrailingSpacesFunction · 0.70
trimRightTrailingSpacesFunction · 0.70
push_backMethod · 0.45

Tested by

no test coverage detected