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

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

博客园 - 程序猿101

2024年总结。。。。2025年规划。 八皇后问题c语言版(xcode下通过) 对分布式一些理解 观察者模式 用redis实现悲观锁(后端语言以php为例) 只用200行Go代码写一个自己的区块链!(转) 用户中心 - 博客园 php的生命周期的概述 linux网络编程1 最简单的socket编程 mysql 慢查询 2016年终总结。。。六年从创业到技术的历程 Linux下chkconfig命令详解 这个简单明了啊 JS的prototype和__proto__ Constructor vagrant homestead laravel 编程环境搭建 发现一个百度的密码。。。记最近一段时间的php感想 mysql 的简单优化 百度面试题 字符串相似度 算法 similar_text 和页面相似度算法 PHP性能优化工具–xhprof安装 Ecshop :后台添加新功能 菜单及 管理权限 配置
百度的面试题 合并两个有序的数组
程序猿101 · 2016-03-03 · via 博客园 - 程序猿101
 1 $a = array(1,3,6,10,29,37,44);
 2 $b = array(2,5,14,19,28,55,73);
 3 $c = array();
 4 
 5 $countA = count($a);
 6 $countB = count($b);
 7 
 8 $pointA = 0;
 9 $pointB = 0;
10 
11 while($pointA < $countA || $pointB < $countB){  //结束条件是两个数组的指针都大于数组的数量
12     if($pointA < $countA && $pointB < $countB){  //分三种情况,两个数组都有数据
13         if($a[$pointA] > $b[$pointB]){  //如果a数组中的大于b数组的,那么把小的一个放在c数组,然后b数组中的指针加1
14             $c[] = $b[$pointB];
15             //echo $pointB;
16             $pointB++;
17         }else{
18             $c[] = $a[$pointA];   //否则的话把a数组的中数组放在c数组中,a的指针加1
19             //echo $pointB;
20             $pointA++;
21         }
22     }elseif($pointA >= $countA){  //a数组的没有数据了
23         $c[] = $b[$pointB];
24         $pointB++;
25     }elseif($pointB >= $countB){
26         $c[] = $a[$pointA];
27         $pointA++;
28     }
29 }
30 echo "<pre>";
31 print_r($c);