惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
L
Lohrmann on Cybersecurity
Google DeepMind News
Google DeepMind News
Schneier on Security
Schneier on Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
The Last Watchdog
The Last Watchdog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News and Events Feed by Topic
P
Proofpoint News Feed
H
Heimdal Security Blog
云风的 BLOG
云风的 BLOG
H
Hacker News: Front Page
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
F
Full Disclosure
小众软件
小众软件
Martin Fowler
Martin Fowler
Security Latest
Security Latest
The Cloudflare Blog
Hacker News: Ask HN
Hacker News: Ask HN
C
Check Point Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
I
InfoQ
AI
AI
Blog — PlanetScale
Blog — PlanetScale
I
Intezer
H
Hackread – Cybersecurity News, Data Breaches, AI and More
M
MIT News - Artificial intelligence
V
Vulnerabilities – Threatpost
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
V2EX
N
News and Events Feed by Topic
C
Cybersecurity and Infrastructure Security Agency CISA
T
Troy Hunt's Blog
大猫的无限游戏
大猫的无限游戏
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Register - Security
The Register - Security
Forbes - Security
Forbes - Security
Recent Announcements
Recent Announcements
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cisco Talos Blog
Cisco Talos Blog
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
S
SegmentFault 最新的问题
S
Securelist
Cloudbric
Cloudbric
T
Tenable Blog
D
Docker

博客园 - GwQ

微软面试智力题(5) 微软面试智力题(4) 微软面试智力题(3) 微软面试智力题(2) 微软面试智力题(1) 微软面试技术题(0) 微软面试技术题(5) 微软面试技术题(4) 微软面试技术题(22) 微软面试技术题(21) 微软面试技术题(20) 微软面试技术题(19) 微软面试技术题(18) 微软面试技术题(17) 微软面试技术题(16) 微软面试技术题(15) 微软面试技术题(13) 微软面试技术题(12) 微软面试技术题(11)
微软面试技术题(14)
GwQ · 2006-06-17 · via 博客园 - GwQ

一个数组,下标从0到n,元素为从0到n的整数。判断其中是否有重复元素。

 1int hasDuplicate(int[] a, int n){
 2    for(int i=0;i<n;++i){
 3        while(a[i]!=&& a[i]!=-1){
 4            if(a[a[i]]==-1return 1;
 5            a[i]=a[a[i]];
 6            a[a[i]]=-1;
 7        }

 8        if(a[i]==i) {a[i]=-1;}
 9    }

10    return 0;
11}