Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

There is an array of length 101, there is a number of 1100, one of which is repeated, find the repetition.

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

There are two ways:

The first way:

A = range (100) random_num = random.randint (0Magne99) print random_num a.insert (random_num,random_num) number = [i for i in an if a.count (I) = = 2] print number [0]

The second way is ordinary traversal.

Print "*" * 10 res = [] for i in a: if i not in res: res.append (I) else: print I # print res

Both of the above methods can be ergodic.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report