2007. Find Original Array From Doubled Array "Python" | LeetCode

Publié le: 15 septembre 2022
sur la chaîne: Sugar Coat
108
1

An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array.

Given an array changed, return original if changed is a doubled array. If changed is not a doubled array, return an empty array. The elements in original may be returned in any order.



Example 1:

Input: changed = [1,3,4,2,6,8]
Output: [1,3,4]
Explanation: One possible original array could be [1,3,4]:
- Twice the value of 1 is 1 * 2 = 2.
- Twice the value of 3 is 3 * 2 = 6.
- Twice the value of 4 is 4 * 2 = 8.
Other original arrays could be [4,3,1] or [3,1,4].
Example 2:

Input: changed = [6,3,0,1]
Output: []
Explanation: changed is not a doubled array.
Example 3:

Input: changed = [1]
Output: []
Explanation: changed is not a doubled array


code: https://github.com/anandchauhan21/dai...

profile:
https://linktr.ee/anandchauhan


Sur cette page du site, vous pouvez voir la vidéo en ligne 2007. Find Original Array From Doubled Array "Python" | LeetCode durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Sugar Coat 15 septembre 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 108 fois et il a aimé 1 téléspectateurs. Bon visionnage!