99일차 - Return the Missing Element
2221 단어 Algorithm DiaryAlgorithm Diary
Fellow code warrior, we need your help! We seem to have lost one of our sequence elements, and we need your help to retrieve it!
Our sequence given was supposed to contain all of the integers from 0 to 9 (in no particular order), but one of them seems to be missing.
Write a function that accepts a sequence of unique integers between 0 and 9 (inclusive), and returns the missing element.
Examples:
[0, 5, 1, 3, 2, 9, 7, 6, 4] --> 8
[9, 2, 4, 5, 7, 0, 8, 6, 1] --> 3
--------------------------------------------🤞 My Solution -----------------------------------------
def get_missing_element(seq):
for i in range(0,10):
if i in seq:
pass
else:
return i
------------------------------------------ Other's Solution ---------------------------------------
def get_missing_element(seq):
return 45 - sum(seq)
Author And Source
이 문제에 관하여(99일차 - Return the Missing Element), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@vivala0519/99일차저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)