
算法
文章平均质量分 85
CristianoJason
宏愿纵未了,奋斗总不太晚。
展开
-
[LeetCode]RemoveDuplicateLetters解题思路
一、问题描述:Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicograp原创 2016-04-27 12:11:54 · 885 阅读 · 0 评论 -
[九度OJ]1042Coincidence
时间限制:1 秒内存限制:32 兆特殊判题:否提交:2852解决:1533题目描述:Find a longest common subsequence of two strings.输入:First and second line of each input case contain two strings of lowe原创 2016-06-30 17:42:27 · 535 阅读 · 0 评论 -
[九度OJ]最短路径
时间限制:1 秒内存限制:32 兆特殊判题:否提交:5046解决:766题目描述:N个城市,标号从0到N-1,M条道路,第K条道路(K从0开始)的长度为2^K,求编号为0的城市到其他城市的最短距离输入:第一行两个正整数N(2接下来M行两个整数,表示相连的两个城市的编号输出:N-1行,表示0号城市到其原创 2016-07-01 00:45:03 · 1156 阅读 · 0 评论 -
[LeetCode]Maximal Rectangle寻找最大矩形
一、 题目描述:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1原创 2016-09-05 00:32:14 · 2511 阅读 · 0 评论 -
[LeetCode]Buy and Sell Stocks 买卖股票问题
LeetCode上关于买卖股票的问题一共有五道,题号分别为121,122,123,188,309。此类问题的基本描述即给出一个序列prices[],prices[i]代表第i天股票的价格。如果当天之前不持有股票,则可以以prices[i]的价格购入股票;如果当天之前持有股票,则可以以prices[i]的价格卖出股票;当然,当天也可任何操作都不进行。目的就是求该阶段的最大收益。原创 2016-09-10 15:22:33 · 4306 阅读 · 0 评论 -
[LeetCode]SudokuSolver解决数独问题
一、 问题描述:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.原创 2016-09-03 16:37:51 · 723 阅读 · 0 评论 -
[Leetcode]Substring with Concatenation of All Words & Minimum Window Substring
这两道题有一定的联系和区别:这类寻找子序列组合的题目大都可以采取双指针+Map的思想进行处理。Substring with Concatenation of All Words中,给定了一些等长的单词words,要求在指定字符串s中找出这些单词的连续组合序列;Minimum Window Substring中,给定了一个子串t,要求在指定字符串s中找出子串t中所有字母所构成的最短子原创 2016-09-03 01:01:20 · 479 阅读 · 0 评论 -
[LeetCode]Majority Element(献上膝盖的一题)
一、问题描述:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the原创 2016-09-06 14:45:52 · 529 阅读 · 0 评论 -
[POJ]3219判断组合数模2结果的奇偶
题目链接:http://poj.org/problem?id=3219Binomial CoefficientsTime Limit: 1000MS Memory Limit: 131072KTotal Submissions: 6875 Accepted: 2872DescriptionThe bin原创 2016-09-19 21:34:17 · 948 阅读 · 0 评论 -
[LeetCode]KMP——字符串匹配
一、问题描述:https://leetcode.com/problems/implement-strstr/Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.原创 2016-04-24 19:53:06 · 4924 阅读 · 0 评论 -
[九度OJ]1091棋盘游戏
时间限制:1 秒内存限制:32 兆特殊判题:否提交:1745解决:481题目描述: 有一个6*6的棋盘,每个棋盘上都有一个数值,现在又一个起始位置和终止位置,请找出一个从起始位置到终止位置代价最小的路径: 1、只能沿上下左右四个方向移动 2、总代价是没走一步的代价之和 3、每步(从a,b到c,d)的代价是c原创 2016-06-29 19:29:53 · 715 阅读 · 0 评论 -
[LeetCode]Multiply Strings
一、问题描述:Given two numbers represented as strings, return multiplication of the numbers as a string.Note:The numbers can be arbitrarily large and are non-negative.Converting the input stri原创 2016-04-20 11:21:39 · 501 阅读 · 0 评论 -
[LeetCode]Candy——分糖果问题
一、问题描述:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must原创 2016-04-27 15:03:30 · 2074 阅读 · 0 评论 -
[LeetCode]Unique Binary Search Trees II生成所有二叉搜索树
一、问题描述:Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below.原创 2016-04-28 22:28:08 · 561 阅读 · 0 评论 -
[LeetCode]Next Permutation下一个排列问题
当初把自己的代码贴在了discuss上,最近有人关于代码部分问了一些问题,现在总结一下这个题目吧。一、问题描述Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such a原创 2016-04-30 00:12:13 · 629 阅读 · 0 评论 -
[AI]模拟退火解决TSP问题(含源码)
模拟退火是一种通用概率算法,用来在固定时间内寻求在一个大的搜寻空间内找到的最优解。模拟退火是S. Kirkpatrick, C. D. Gelatt和M. P. Vecchi在1983年所发明。而V. Černý在1985年也独立发明此算法。(摘自Wiki百科:https://zh.wikipedia.org/wiki/%E6%A8%A1%E6%8B%9F%E9%80%80%E7%81%AB)原创 2015-12-02 14:14:29 · 2247 阅读 · 0 评论 -
[AI](加入随机因素)局部搜索解决N皇后问题(含源码)
局部搜索算法(加入随机因素):主要思想是要想得到全局最优解,总沿着局部最优的方向寻找,但会存在局部最优陷阱,即到达一个极值点(非最值点),在其邻域内无法找到更优解,所以需要多次尝试。a) 变量: i. N:皇后个数; ii. 皇后位置数组Pos[N]:下标为行号,对应值为列号; iii.原创 2016-03-23 16:55:08 · 2732 阅读 · 2 评论 -
[AI]根据葡萄特征聚类
对给定的55种葡萄进行聚类分析,真实数据分为红葡萄和白葡萄两类,要求根据每种葡萄的特征向量x=(x1,x2,…,x6)采用聚类分析这些数据的特点,并根据真实数据验证聚类的准确性。聚类,简单地说就是把相似的东西分到一组。聚类的时候我们并不关心某一类是什么,需要实现的目标只是把相似的东西聚到一起,因此,一个聚类算法通常只需要知道如何计算相似度就可以开始工作了,聚类因此在Machine Learni原创 2016-03-23 17:07:32 · 1553 阅读 · 1 评论 -
[AI]人工神经网络对葡萄酒打分
人工神经网络(artificial neural network,缩写ANN),简称神经网络(neural network,缩写NN)或类神经网络,是一种模仿生物神经网络(动物的中枢神经系统,特别是大脑)的结构和功能的数学模型或计算模型。神经网络由大量的人工神经元联结进行计算。大多数情况下人工神经网络能在外界信息的基础上改变内部结构,是一种自适应系统。现代神经网络是一种非线性统计性数据建模工具,常原创 2016-05-26 17:58:35 · 1979 阅读 · 0 评论 -
[算法]移位与旋转
下午实习机试遇到一道题目: 一个长为N的顺序表L存放了N个元素,给定p,要求将(X0, X1, ..., Xn-1)循环左移p位得到(Xp, Xp+1, ..., Xn-1, X0, X1, ..., Xp-1)。 好吧我承认当时没想太多,因为N不大直接又开了个数组按照映射关系直接拷过去了...... 今晚复习数据结构的时候遇到了一个基本一模一样的题目,决定好原创 2016-04-22 23:01:32 · 1338 阅读 · 0 评论 -
ACM规划
一位高手对我的建议:一般要做到50行以内的程序不用调试、100行以内的二分钟内调试成功.acm主要是考算法的,主要时间是花在思考算法上,不是花在写程序与debug上。 下面给个计划你练练:第一阶段:练经典常用算法,下面的每个算法给我打上十到二十遍,同时自己精简代码,因为太常用,所以要练到写时不用想,10-15分钟内打完,甚至关掉显示器都可以把程序打出来. 1转载 2016-09-21 11:02:10 · 655 阅读 · 0 评论