Linked List Random Node - Leetcode 382 - Python

Publié le: 10 mars 2023
sur la chaîne: Lit Code
21
0

Leetcode Daily Challenge - March 10, 2023
Leetcode 382. Linked List Random Node - Python Solution

Solution URL: https://leetcode.com/problems/linked-...

Problem Statement
Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen.

Implement the Solution class:

Solution(ListNode head) Initializes the object with the head of the singly-linked list head.
int getRandom() Chooses a node randomly from the list and returns its value. All the nodes of the list should be equally likely to be chosen.

===================================================

Support the channel by subscribing and hitting the like button.

Litcode Playlist: https://bit.ly/3uGBSHx

LinkedIn:   / sachin-singh-ss31  
Email: sachinsingh31@outlook.com

#leetcode #leetcodesolution #leetcodedailychallenge #codingpractice #learnpython #python #googleinterview #amazoninterviewpreparation


Sur cette page du site, vous pouvez voir la vidéo en ligne Linked List Random Node - Leetcode 382 - Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Lit Code 10 mars 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 21 fois et il a aimé 0 téléspectateurs. Bon visionnage!