From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/linked_list_random.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 other/linked_list_random.cpp (limited to 'other/linked_list_random.cpp') diff --git a/other/linked_list_random.cpp b/other/linked_list_random.cpp deleted file mode 100644 index ae147c5..0000000 --- a/other/linked_list_random.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// 382. Linked List Random Node -#include "leetcode.h" - -/* - * given singly linked list, return a random node's value from the linked list. - * each node must have the same probability of being chosen. implement - * 'Solution' class: f1: initialises object with head of signly linked list - * 'head' f2: chooses node randomly from list and returns its value. all nodes - * should be equally likely to be chosen - */ - -class Solution { -public: - Solution(ListNode *head) { - this->head = head; - while (head != NULL) { - this->n++; - head = head->next; - } - } - int getRandom() { - int i = rand() % this->n; - ListNode *p = this->head; - while (i) { - p = p->next; - i -= 1; - } - return p->val; - } - -private: - int n = 0; - ListNode *head = NULL; -}; - -int main() { - ListNode *head; - Solution *obj = new Solution(head); - int param_1 = obj->getRandom(); -} -- cgit v1.2.3