摘要:
最近因为研究需要,在MAC的操作系统中需要同时安装python2和python3;最开始mac系统已经安装anaconda并且默认自带python3,如图所示输入python,可以查看当前python版本 输入以下指令可以查看有哪些安装包 如果想同时安装python2,只需要重新配置环境变量,以安装 阅读全文
摘要:
这里强烈推荐一个博主写的二分搜索总结:http://www.cnblogs.com/grandyang/p/6854825.html 参考链接: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sort 阅读全文
摘要:
这道题目很经典,本人表示在面试时遇见过,要求复杂度为O(logn),很显然必须用二分查找,但是旋转导致数组并非从左到右都是有序的,因此我们在查找时需要做判断,我们找打的终点左边或者右边至少一边是有序的;如果中间数小于最右边的数字,则右半段是有序的;如果中间数字大于最右边数字,则左半段是有序的,参考下 阅读全文
摘要:
一、基础代码 1、已知一个三角形三个顶点坐标,求三角形面积 解:这道题没啥特殊的方法,用的是海伦公式,三角形面积S,三条边长分别为a,b,c设 p = (a+b+c)/2,则三角形面积可以表示为: \[S = \sqrt {p(p - a)(p - b)(p - c)} \] 2、已知两个矩形的左上 阅读全文
摘要:
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [ 阅读全文
摘要:
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: 阅读全文
摘要:
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Op 阅读全文
摘要:
2018.10.26 今天去中国人大参加了“中国保信”的笔试,题目是50道行测+2个小作文+1个大作文,话说今天写的字恐怕比我往常一年写的字都要多,想想就觉得可怕,让我找回了高中时做语文卷子的感觉,有一道数学题很有意思,当时我没做出来,后来自己想了想,这道题时可以做到 题目:摩托车有俩轮胎,前轮可以 阅读全文
摘要:
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to le 阅读全文
摘要:
今天做了“去哪儿”的笔试,编程题并不难,但是卡在输入数据上了,数据读都读不进来,很让人恼火。 一般的题目输入数据会是这样:第一行:一个整数n,表示数组长度 (6)第二行:n个整数,之间用空格隔开 (1 4 1 1 5 6) 但是去哪儿的题目挺奇怪,输入只有一行 第一行:输入n个整数,以空格隔开 (1 阅读全文