
算法分析与设计
小学生Jason
简简单单,认认真真。
展开
-
面试算法---排列组合AC的实现
一:基础知识1.排列公式Anm是指从n个元素取m个进行排列(即排序).操作步骤:先从n个元素中选取m个元素,再进行排序.(一共有Anm种排列)2.组合公式Cnm是指从n个元素取m个不进行排列(即不排序)操作步骤:只需从n个元素中选取m个元素就好,不须要排序.(一共有Cnm中取法)3.例如 从A、B、C 3个字母取2个字母进行排列,有6种:AB AC BA BC CA CB原创 2015-05-20 09:55:19 · 5410 阅读 · 0 评论 -
LeetCode_7---Reverse Integer
LeetCode原创 2015-06-02 11:37:07 · 343 阅读 · 0 评论 -
LeetCode_11---Container With Most Water
LeetCode原创 2015-06-02 16:49:41 · 361 阅读 · 0 评论 -
LeetCode_13---Roman to Integer
LeetCode原创 2015-06-03 15:12:22 · 327 阅读 · 0 评论 -
LeetCode_12---Integer to Roman
LeetCode原创 2015-06-03 13:28:49 · 438 阅读 · 0 评论 -
LeetCode_15---3Sum
LeetCode原创 2015-06-04 09:41:55 · 331 阅读 · 0 评论 -
LeetCode_14---Longest Common Prefix
LeetCode原创 2015-06-03 16:35:58 · 302 阅读 · 0 评论 -
LeetCode_16---3Sum Closest
LeetCode原创 2015-06-04 11:45:01 · 434 阅读 · 0 评论 -
LeetCode_17---Letter Combinations of a Phone Number
LeetCode原创 2015-06-04 14:06:07 · 394 阅读 · 0 评论 -
LeetCode_20---Valid Parentheses
LeetCode原创 2015-06-05 15:34:37 · 335 阅读 · 0 评论 -
算法基础---全排列算法
(一)递归的全排列算法(A、B、C、D)的全排列为1、A后面跟(B、C、D)的全排列2、B后面跟(A、C、D)的全排列3、C后面跟(A、B、D)的全排列4、D后面跟(A、B、C)的全排列而对1中的(B、C、D)照样可以按照上面的形式进行分解。/** * */package test;/** * @author MohnSnow原创 2015-06-29 14:43:47 · 405 阅读 · 0 评论 -
排序算法---快速排序(JDK1.7 DualPivotQuicksort 源码解析)
Arrays.sort()方法源码解析。源码一: /** * Sorts the specified range of the array. * * @param a the array to be sorted * @param left the index of the first element, inclusive, to be s原创 2015-06-11 16:40:16 · 1751 阅读 · 0 评论 -
算法基础---动态规划
一:通过金矿模型介绍动态规划连接二:代码部分Code:package DynamicProgarmming;import java.util.ArrayList;import java.util.HashMap;/** * @author MohnSnow * @time 2015年6月15日 上午10:19:55 * @title 有一个包和n个物品,包的容量为m原创 2015-06-15 13:26:46 · 336 阅读 · 0 评论 -
LeetCode_8---String to Integer (atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input case原创 2015-06-02 14:29:44 · 383 阅读 · 0 评论 -
LeetCode_10---Regular Expression Matching
LeetCode原创 2015-06-02 15:35:27 · 315 阅读 · 0 评论 -
算法之道---寻找多数元素算法(Java)
定义: 整型数组a[1...n],如果整数x在数组a中出现的次数多于半数,则x称为多数元素应用概念:观察结论5.1:在原序列中去除两个不同的元素后,那么在原序列中的多数元素在新序列中还是多数元素。例1: 1,2,2,3,2,2,3 显然2是多数元素去除1,2,在2,3,2,2,3中2仍是多数元素去除1,3,在2,3,2,2,3中2更是多数元素例原创 2015-05-21 14:13:26 · 740 阅读 · 0 评论 -
LeetCode_1---Two Sum
LeetCode_1---Two Sum原创 2015-05-28 13:51:05 · 342 阅读 · 0 评论 -
CTCI---8.1.1
题目:实现一个算法,确定一个字符串的所有字符全都不同。家是不允许使用额外的数据结构,又该如何处理。/** * */package Chapter_8;import java.util.Scanner;/** * @author MohnSnow * @time 2015年5月21日 下午5:27:32 * */public class chapter8_1_1 {原创 2015-05-21 17:20:43 · 384 阅读 · 0 评论 -
LeetCode_2---Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link原创 2015-05-28 15:12:01 · 316 阅读 · 0 评论 -
LeetCode_4---Median of Two Sorted Arrays
leetcode原创 2015-05-29 11:10:34 · 422 阅读 · 0 评论 -
LeetCode_3---Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For原创 2015-05-28 17:45:48 · 342 阅读 · 0 评论 -
算法基础----关于数据结构中树的相关算法总结探究
1,分层遍历二叉树。算法步骤:(使用队列),将根结点指针入队。,将根结点指针出队,如果出队结点的左右孩子存在的话, 将出队结点的左右孩子入队。并输出出队结点的数据。,判断队列是否为空,如果为空,算法结束,否则转至.package TreeAlgorithms;import java.util.ArrayList;import java.util.Arra原创 2015-06-18 13:54:42 · 448 阅读 · 0 评论 -
算法基础----关于数据结构中图的相关算法总结探究
package MapAlgorithms;import java.util.ArrayList;import java.util.LinkedList;import java.util.Queue;/** * @author MohnSnow * @time 2015年6月18日 下午3:52:18 * */public class Graph { public sta原创 2015-06-18 16:10:30 · 386 阅读 · 0 评论 -
LeetCode_5---Longest Palindromic Substring (求最长回文子串)
/** * *//** * @author MohnSnow * @time 2015年5月29日 下午2:24:31 * */public class LeetCode5 { /** * @param argsmengdx * -fnst */ /* * 方法1两侧比较法,其实就是暴力方法 */ public static原创 2015-06-01 16:48:56 · 463 阅读 · 0 评论 -
LeetCode_6---ZigZag Conversion
LeetCode原创 2015-06-01 16:54:40 · 420 阅读 · 0 评论 -
LeetCode_9---Palindrome Number
LeetCode原创 2015-06-02 15:01:52 · 366 阅读 · 0 评论 -
排序算法---基础算法(冒泡排序,快速排序,选择排序,直接插入排序,桶排序)
一:桶排序部分使用条件:1.空间明确2.对时间要求要求高简介:桶的个数固定,每一桶中统计这个数出现的次数Code:package sort;import java.util.Arrays;/** * @author MohnSnow * @time 2015年6月11日 上午9:40:07 * @title 桶排序 * */public class Bucke原创 2015-06-11 16:15:48 · 878 阅读 · 0 评论