![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
Ethan. L
iOS guy
展开
-
算法-快速排序
/* * 快速排序(C实现) 1.i =L; j = R; 将基准数挖出形成第一个坑a[i]。 2.j--由后向前找比它小的数,找到后挖出此数填前一个坑a[i]中。 3.i++由前向后找比它大的数,找到后也挖出此数填到前一个坑a[j]中。 4.再重复执行2,3二步,直到i==j,将基准数填入a[i]中。 */void quick_sort(int s[], int l, int r)...原创 2018-02-26 10:30:20 · 310 阅读 · 0 评论 -
算法-寻找二叉树两个结点的最低共同父节点(OC实现)
要求:正向遍历(父节点能访问到子节点,子节点不能访问父节点)1.用plist文件模拟一个二叉树:2.具体实现:- (void)viewDidLoad { [super viewDidLoad]; NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Tree" ofType:@"plist"]; NSDictionar...原创 2018-02-07 17:37:44 · 937 阅读 · 0 评论 -
算法-TwoSum
题目:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same...原创 2018-02-08 09:49:07 · 342 阅读 · 0 评论 -
算法-Longest Common Prefix【swift4实现】
原题连接:https://leetcode.com/problems/longest-common-prefix/description/解决:func longestCommonPrefix(_ strs: [String]) -> String { if strs.count == 0 { return "" } else if...原创 2018-12-12 15:11:34 · 277 阅读 · 0 评论