#include <leetcode.h>
◆ Solution()
leetcode::linked_list_random_node::Solution::Solution |
( |
ListNode * | head | ) |
|
|
inlineexplicit |
◆ getRandom()
int leetcode::linked_list_random_node::Solution::getRandom |
( |
| ) |
const |
|
nodiscard |
在文件 leetcode.cpp 第 1035 行定义.
1035 {
1036 int i = 1;
1038 for(
const auto *node =
head; node !=
nullptr; node = node->next, i++) {
1039 if(rand() % i == 0) {
1040
1042 }
1043 }
1045 }
vector< vector< int > > ans
引用了 head.
◆ head
ListNode* leetcode::linked_list_random_node::Solution::head |
|
private |
该类的文档由以下文件生成: