冒泡排序
四则运算表达式求值
四则运算表达式求值两个要点1.中缀表达式转后缀表达式2.后缀表达式求值中缀表达式转后缀表达式从左到右遍历中缀表达式的每个数字和符号.若是数字就输出,成为后缀表达式的一部分.若是符号则判断其与栈顶符号的优先级,是右括号或者优先级低于等于栈顶符号,则栈顶元素依次出栈并输出,再将当前的符号进栈。一直到最终输...
二进制字符串相加
转载自:https://leetcode.com/problems/add-binary/discuss/洋人写的好优雅啊
判断是否是回文数字
解题思路: 这道题很明显是一道数学题,计算一个数字是否是回文数字,我们其实就是将这个数字除以10,保留他的余数,下次将余数乘以10,加上这个数字再除以10的余数.负数不是回文数字.0是回文数字.
给定数字生成中文数字
public class T { public static void main(String[] args) { int i=123456789; Solution s=new Solution(); &...
Reverse Integer
click to show spoilers.
Two Sum
You may assume that each input would have exactly one solution, and you may not use the same element twice.Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 2 + 7 = 9,return [0, 1].https://leetcode.com/problems/two-sum/description/我想出来的办法,简单...
Longest Substring Without Repeating Characters
Given a string, find the length of the without repeating characters.Examples:Given , the answer is , which the length is 3.Given , the answer is , with the length of 1.Given , the answer is , with the length of 3. Note that the answer must be a ,...
三向切分的快速排序和优化
public class Sort{ public static void main(String[] args){ Integer[] data={100,20,21,28,22,26,80,33,3,2,9,8,7,10,77,66,99,96,91,94}; BaseSort...
二叉堆优先队列
public class MaxPQ <Key extends Comparable<Key>> { private Key[] pq; private int N=0; public MaxPQ(int maxN){ pq=(Key[])new Comparabl...
快速排序
public class Sort{ public static void main(String[] args){ Integer[] data={100,20,21,28,22,26,80,33,3,2,9,8,7,10,77,66,99,96,91,94}; BaseSort...
归并排序
希尔排序
public class Sort{ public static void main(String[] args){ Integer[] data={3,2,9,8,7,10}; BaseSort s=new Shell(); &n...
选择排序和插入排序
publicclass main(String[] args){ 3298710 BaseSort s= Insertion(); s.sort(data); &nb...
KMP字符串模式匹配
<span style="font-family:'Courier New';"><span style="font-size:16px;color:#003399;">参考:<br />http://www.ruanyifeng.com/blog/2013/05/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm.html<br /><br />http://blog.csdn.net/v_july_v/article/details/7041827<br /><br /><br /><div id="codeText" class="c...
字符串模式匹配(粗暴版)
<span style="font-family:Courier New;"><span style="font-size:16px;"><span style="color:#003399;">简单,粗暴,可能还有Bug<br /><br /><img src="/attachment/201508/26/29254281_1440584466EsgW.png" width="700" height="603.28317373461" alt="" /><br /><br /><br /><div id="codeText" class="codeText">...