本博客rss订阅地址: http://feed.cnblogs.com/blog/u/147990/rss
摘要: 最近在准备找工作的算法题,刷刷LeetCode,以下是我的解题报告索引,每一题几乎都有详细的说明,供各位码农参考。根据我自己做的进度持续更新中...... 本文地址LeetCode:Reverse Words in a StringLeetCode:Evaluate Reverse Polish N... 阅读全文
posted @ 2013-11-20 23:09 tenos 阅读(9975) 评论(0) 推荐(0) 编辑
摘要: 最近在用latex写毕业论文,编辑环境用的是Sublime Text 2 加 latextools 插件,在使用latextools的\cite命令来引用参考文献时,我们希望输入\cite{ 后自动弹出所有参考文献提示,本文总结一下设置过程中遇到的坑。首先要保证设置文件LaTeXTools.defa... 阅读全文
posted @ 2014-12-25 16:47 tenos 阅读(6758) 评论(0) 推荐(1) 编辑
摘要: mac从源码编译安装是最方便的,lua源码不足两万行,编译几秒钟的事。打开terminal,依次输入以下命令:curl -R -O http://www.lua.org/ftp/lua-5.2.3.tar.gztar zxf lua-5.2.3.tar.gzcd lua-5.2.3make maco... 阅读全文
posted @ 2014-12-22 17:29 tenos 阅读(2167) 评论(0) 推荐(0) 编辑
摘要: 对于凸多边形,很容易计算,如下图,以多边形的某一点为顶点,将其划分成几个三角形,计算这些三角形的面积,然后加起来即可。已知三角形顶点坐标,三角形面积可以利用向量的叉乘来计算。 对于凹多边形,如果还是按照上述方法划分成三角形,如下图,多边形的面积 = S_ABC + S_ACD + S_ADE, 这个面积明显超过多边形的面积。 我们根据二维向量叉乘求三角形ABC面积时,利用... 阅读全文
posted @ 2014-10-24 00:04 tenos 阅读(61939) 评论(5) 推荐(6) 编辑
摘要: 一把武器,最低是1级,最高可以升到9级,每次升级成功率30%,失败率70%。失败会退一级,在1级的时候如果失败则仍然为1级。问:该武器从1级升到9级的所需次数的期望?记从第k-1级升到第k级所需次数的期望是E_k。假设武器处于k级,那么从k级升到k+1所需次数的期望E_(k+1) 如何求呢? 分为两... 阅读全文
posted @ 2014-10-23 14:37 tenos 阅读(1746) 评论(0) 推荐(0) 编辑
摘要: 代码在每一章节最后 一、均匀生成圆内的随机点 我们知道生成矩形内的随机点比较容易,只要分别随机生成相应的横坐标和纵坐标,比如随机生成范围[-10,10]内横坐标x,随机生成范围[-20,20]内的纵坐标y,那么(x,y)就是生成的随机点。由此,我们很容易的想到了算法1 算法1(正确的): 每个圆对应一个外切矩形,我们随机生成矩形内的点,如果该点在圆内,就返回改点,否则重新生成... 阅读全文
posted @ 2014-10-14 21:15 tenos 阅读(17566) 评论(4) 推荐(6) 编辑
摘要: 最近在项目中碰到的这个问题,在此记录一下。已知三角形的三个顶点坐标,判断某个点是否在三角形中(在三角形的边上,我们也视作在三角形中),本文给出了三种方法。算法1利用面积法,如上图所示,如果点P在三角形ABC的内部,则三个小三角形PAB, PBC, PAC的面积之和 = ABC的面积,反之则不相等。已... 阅读全文
posted @ 2014-10-14 14:51 tenos 阅读(34470) 评论(13) 推荐(4) 编辑
摘要: 官方的安装帮助页面:http://pip.readthedocs.org/en/latest/installing.htmlwindows:下载代码get-pip.py, 运行该代码, 这个代码会自动安装setuptools工具和pip把python安装文件夹下的Script目录加入环境变量path... 阅读全文
posted @ 2014-09-29 16:42 tenos 阅读(5968) 评论(0) 推荐(0) 编辑
摘要: 题目链接Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the". 1 class Solution { 2 publ... 阅读全文
posted @ 2014-09-22 19:59 tenos 阅读(1177) 评论(0) 推荐(1) 编辑
摘要: 声明:本文转自伯乐在线-Jerry,原文地址:http://blog.jobbole.com/68023/由于某些怪异的原因,下面这段C++代码表现的异乎寻常—-当这段代码作用于有序数据时其速度可以提高将近6倍,这真是令人惊奇。123456789101112131415161718192021222... 阅读全文
posted @ 2014-09-18 16:39 tenos 阅读(766) 评论(0) 推荐(0) 编辑
摘要: 题目链接 Write a function to find the longest common prefix string amongst an array of strings. 题目的意思说的不是很清楚,开始理解成了求任意两个字符串的前缀中的最长者。但是本题的意思是求所有字符串的最长公共前缀,即数组的所有字符串都包含这个前缀。 算法1:逐个字符比较,时间复杂度为O(N*L),N是... 阅读全文
posted @ 2014-07-20 16:11 tenos 阅读(11509) 评论(0) 推荐(0) 编辑
摘要: Container With Most Water 题目链接 Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is... 阅读全文
posted @ 2014-06-28 00:18 tenos 阅读(5054) 评论(0) 推荐(0) 编辑
摘要: 题目链接You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a conca... 阅读全文
posted @ 2014-06-24 22:33 tenos 阅读(2546) 评论(0) 推荐(0) 编辑
摘要: 题目链接Implement pow(x, n).主要利用x^2n = (x^n)*(x^n), x^2n+1 = (x^n)*(x^n)*x注意n是负数,对其取反时,可能会溢出其实0^0(都是整数)是未定义的,因为0^0 = 0^1 / 0^1 = 0 / 0, 0作为除数是未定义的,可以参考维基百... 阅读全文
posted @ 2014-06-22 20:11 tenos 阅读(1016) 评论(0) 推荐(0) 编辑
摘要: Combination Sum Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C u... 阅读全文
posted @ 2014-06-22 15:49 tenos 阅读(1580) 评论(0) 推荐(1) 编辑
摘要: N-QueensThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, retu... 阅读全文
posted @ 2014-06-21 23:02 tenos 阅读(13838) 评论(0) 推荐(0) 编辑
摘要: Valid SudokuDetermine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are... 阅读全文
posted @ 2014-06-21 00:41 tenos 阅读(7422) 评论(3) 推荐(0) 编辑
摘要: 题目链接 Divide two integers without using multiplication, division and mod operator. 最直观的方法是,用被除数逐个的减去除数,直到被除数小于0。这样做会超时。 本文地址 那么如果每次不仅仅减去1个除数,计算速度就会增加,但是题目不能使用乘法,因此不能减去k*除数,我们可以对除数进行... 阅读全文
posted @ 2014-06-18 20:58 tenos 阅读(5272) 评论(1) 推荐(0) 编辑
摘要: 题目链接 Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as i... 阅读全文
posted @ 2014-06-18 14:04 tenos 阅读(988) 评论(0) 推荐(0) 编辑
摘要: 题目链接 Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space... 阅读全文
posted @ 2014-06-17 22:38 tenos 阅读(678) 评论(0) 推荐(0) 编辑
摘要: 题目链接 Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn't matter what you leave beyond the new length. ... 阅读全文
posted @ 2014-06-17 22:13 tenos 阅读(668) 评论(0) 推荐(0) 编辑
摘要: 首先简单介绍一下罗马数字,一下摘自维基百科罗马数字共有7个,即I(1)、V(5)、X(10)、L(50)、C(100)、D(500)和M(1000)。按照下述的规则可以表示任意正整数。需要注意的是罗马数字中没有“0”,与进位制无关。一般认为罗马数字只用来记数,而不作演算。重复数次:一个罗马数字重复几... 阅读全文
posted @ 2014-06-17 21:17 tenos 阅读(5457) 评论(0) 推荐(2) 编辑
摘要: 这几天帮同学写了个简单的gui应用,用的qt5.0.2_msvc2010。写的程序需要在一台没有装过vs和qt的机子上运行。 在release下编译运行通过后,把相应的依赖dll加入到exe相同的文件夹,我们可以使用dependency walk或者ProcessExplorer查询exe依赖的dll。 添加如下的dll后,exe就可以在其他的机子上运行 dll在 文件夹 “G:\so... 阅读全文
posted @ 2014-06-17 15:35 tenos 阅读(692) 评论(0) 推荐(0) 编辑
摘要: 题目链接Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((... 阅读全文
posted @ 2014-06-08 18:52 tenos 阅读(2039) 评论(0) 推荐(0) 编辑
摘要: 题目链接Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the corr... 阅读全文
posted @ 2014-06-08 16:39 tenos 阅读(590) 评论(0) 推荐(0) 编辑
摘要: 题目链接The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off a... 阅读全文
posted @ 2014-06-08 16:12 tenos 阅读(7357) 评论(0) 推荐(3) 编辑
摘要: 题目链接 Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or righ... 阅读全文
posted @ 2014-06-07 15:00 tenos 阅读(3715) 评论(0) 推荐(0) 编辑
摘要: Spiral MatrixGiven a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, Given the following ... 阅读全文
posted @ 2014-06-07 14:17 tenos 阅读(1688) 评论(0) 推荐(1) 编辑
摘要: 题目链接Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the tele... 阅读全文
posted @ 2014-06-05 22:17 tenos 阅读(3717) 评论(0) 推荐(1) 编辑
摘要: 题目链接Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the... 阅读全文
posted @ 2014-06-05 21:00 tenos 阅读(1480) 评论(1) 推荐(1) 编辑
摘要: 题目链接Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not pos... 阅读全文
posted @ 2014-06-05 13:01 tenos 阅读(1322) 评论(0) 推荐(0) 编辑
摘要: 题目链接 Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses con... 阅读全文
posted @ 2014-06-05 12:06 tenos 阅读(829) 评论(0) 推荐(0) 编辑
摘要: 题目链接 You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? ... 阅读全文
posted @ 2014-06-04 21:39 tenos 阅读(1611) 评论(0) 推荐(0) 编辑
摘要: Kepler(开普勒,1571年12月27日-1630年11月15日),德国天文学家、数学家,十七世纪科学革命的关键人物。这样一位伟大的人物在1611年遇到一个问题,他的夫人患匈牙利斑疹伤寒(Hungarian spotted feve)过世,为了照顾孩子、打理家务,Kepler 需要重新寻找一位夫... 阅读全文
posted @ 2014-05-23 16:10 tenos 阅读(8809) 评论(11) 推荐(6) 编辑
摘要: 一个n*m的网格,求这个网格中矩形的数目。 比如以下2*2网格,总共有9个矩形:4个1*1的矩形,4个1*2的矩形,1个2*2的矩形 算法1:动态规划,假设dp[i][j]表示以第 i 行第 j 列的格子为右下角顶点的矩形数目,那么dp[i][j] = 1 + dp[i-1][j] + dp[i][j-1] – dp[i-1][j-1] , 这里的1表示i ,j 位置的格子自身构成1... 阅读全文
posted @ 2014-05-20 22:10 tenos 阅读(5103) 评论(0) 推荐(2) 编辑
摘要: 题目链接The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed f... 阅读全文
posted @ 2014-05-20 13:19 tenos 阅读(6261) 评论(0) 推荐(0) 编辑
摘要: 题目链接Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letter... 阅读全文
posted @ 2014-05-19 14:09 tenos 阅读(2152) 评论(0) 推荐(0) 编辑
摘要: 题目链接 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you thought about this? Here are some good questions to ask before coding. Bonus points ... 阅读全文
posted @ 2014-05-18 22:44 tenos 阅读(2010) 评论(0) 推荐(0) 编辑
摘要: 题目链接 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 ... 阅读全文
posted @ 2014-05-18 16:56 tenos 阅读(823) 评论(0) 推荐(0) 编辑
摘要: 题目链接Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-... 阅读全文
posted @ 2014-05-18 16:19 tenos 阅读(6372) 评论(0) 推荐(4) 编辑
摘要: 关于缓冲区的详细介绍,请参考 C++编程对缓冲区的理解 CPP的输入输出流和缓冲区 c++输出缓冲区刷新 (1)c++中cin、cout,cerr和c的stdin、stdout、stderr都是同步的,即iostream 对象和 and cstdio流是同步的,同步关系如下: 同步即表明我们可以在程序中混合用cout和printf或其他对应的流对。可以用std::ios_ba... 阅读全文
posted @ 2014-05-16 22:46 tenos 阅读(4816) 评论(1) 推荐(3) 编辑

本博客rss订阅地址: http://feed.cnblogs.com/blog/u/147990/rss

公益页面-寻找遗失儿童