C++代码之 常用算法汇总
2015-08-18 22:07
351 查看
算法–基础
排序–插入排序–直接插入排序 代码
排序–插入排序–折半插入排序 代码
排序–插入排序–两路插入排序 代码
排序–插入排序–希尔排序 代码
排序–交换排序–冒泡排序 代码
排序–交换排序–快速排序 代码
排序–选择排序–简单选择排序 代码
排序–选择排序–堆排序 代码
一个字符串,里面只有三种字符RGB 所有的R都在G的前面,所有的G都在B的前面, 将给定字符串按照此规律排序。
要求不允许用辅助空间,复杂度控制在O(N),遍历一遍。
解法 1 代码
2015-08-21 longest common sub–string, IGT
Please implement a function to find the longest common sub–string of two given string.
For example:
string a: abcdefg12345
string b: cdef234
longest common sub–string:cdef
解法 1 代码
2015-08-21 Expression AmazonTest2012Q1
Question: From AmazonTest2012Q1
Given an array with positive integers and another integer.
for example{7 2 4} 9, you are required to generate an equation,
by inserting operator add (“+”) and minus (“-“) among the array.
The left side of equation are consist of the array and the right
side of equation is the integer. here the result is 7-2+4=9
Rules:
Don’t include any space in the generated equation.
In case there is no way to create the equation, please output “Invalid”.
For example {1 1} 10, output is “Invalid”
The length of the integer array is from 1 to 15( include 1 and 15). If
the length is 1, for example the input {7} 7, the output is 7=7
There is no operator “+” or “-” in front of the first number:
Don’t change the order of the numbers. For example: {7 2 4} 9. 7-2+4=9 is
correct answer, 4-2+7=9 is wrong answer.
There could be multiple input, meaning your function could be called
multiple times. Do remember print a new line after the call.
[解法 1 代码] Working
2015-08-25 字符串中包含唯一字符的最长子串
Question: Given a string, find the longest sub sequence
which contains only unique characters.
解法 1 代码
排序–插入排序–直接插入排序 代码
排序–插入排序–折半插入排序 代码
排序–插入排序–两路插入排序 代码
排序–插入排序–希尔排序 代码
排序–交换排序–冒泡排序 代码
排序–交换排序–快速排序 代码
排序–选择排序–简单选择排序 代码
排序–选择排序–堆排序 代码
算法–面试题
2015-08-20 RGB Problem, IGT –字符串类一个字符串,里面只有三种字符RGB 所有的R都在G的前面,所有的G都在B的前面, 将给定字符串按照此规律排序。
要求不允许用辅助空间,复杂度控制在O(N),遍历一遍。
解法 1 代码
2015-08-21 longest common sub–string, IGT
Please implement a function to find the longest common sub–string of two given string.
For example:
string a: abcdefg12345
string b: cdef234
longest common sub–string:cdef
解法 1 代码
2015-08-21 Expression AmazonTest2012Q1
Question: From AmazonTest2012Q1
Given an array with positive integers and another integer.
for example{7 2 4} 9, you are required to generate an equation,
by inserting operator add (“+”) and minus (“-“) among the array.
The left side of equation are consist of the array and the right
side of equation is the integer. here the result is 7-2+4=9
Rules:
Don’t include any space in the generated equation.
In case there is no way to create the equation, please output “Invalid”.
For example {1 1} 10, output is “Invalid”
The length of the integer array is from 1 to 15( include 1 and 15). If
the length is 1, for example the input {7} 7, the output is 7=7
There is no operator “+” or “-” in front of the first number:
Don’t change the order of the numbers. For example: {7 2 4} 9. 7-2+4=9 is
correct answer, 4-2+7=9 is wrong answer.
There could be multiple input, meaning your function could be called
multiple times. Do remember print a new line after the call.
[解法 1 代码] Working
2015-08-25 字符串中包含唯一字符的最长子串
Question: Given a string, find the longest sub sequence
which contains only unique characters.
解法 1 代码
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- 关于指针的一些事情
- c++ primer 第五版 笔记前言
- share_ptr的几个注意点
- 动易2006序列号破解算法公布
- Ruby实现的矩阵连乘算法
- C#插入法排序算法实例分析
- Lua中调用C++函数示例
- Lua教程(一):在C++中嵌入Lua脚本
- Lua教程(二):C++和Lua相互传递数据示例
- 超大数据量存储常用数据库分表分库算法总结
- C#数据结构与算法揭秘二
- C#冒泡法排序算法实例分析
- 算法练习之从String.indexOf的模拟实现开始
- C#算法之关于大牛生小牛的问题
- C++联合体转换成C#结构的实现方法
- C#实现的算24点游戏算法实例分析
- C++编写简单的打靶游戏
- C++ 自定义控件的移植问题
- C++变位词问题分析