Linked List Random Node - Leetcode 382 - Python

Publicado em: 10 Março 2023
no canal de: 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


Nesta página do site você pode assistir ao vídeo on-line Linked List Random Node - Leetcode 382 - Python duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Lit Code 10 Março 2023, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 21 vezes e gostou 0 espectadores. Boa visualização!