自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(157)
  • 收藏
  • 关注

原创 Two Sum

这是我用Python刷的第一个题。我刚开始用python,并且第一次刷leetCode,和我以前刷过的网站不太一样,我还是按以前的办法处理,导致浪费了很多时间去,但是体验挺不错的,同时也感觉到了英语的重要性。一开始用暴力破解,时间复杂度为n的平方,在第18个测试用例上导致超时。所以必须得换,但是没想出来[衰]。看到网上有这种方法,就翻译为python了。class Solution(object

2017-07-06 19:10:58 180

原创 Python,函数

1、函数定义 函数定义通过关键字def语句,在def关键字之后依次写出函数名、参数和冒号,我经常忘记冒号[衰].如果要定义空函数,则可以按如下定义,def functionName(): pass2、函数返回值 函数可以有多个返回值,但是这些返回值会建立一个tuple并且返回。 3、函数参数 3.1 默认参数 默认参数我们可以不用进行显式赋值,该参数有默认值。>>

2017-07-04 21:20:19 273

原创 Python,set数据类型

本人所用的Python版本为:2.7.13 1、创建set集合 创建set类集合的参数必须是迭代器类型,即list、dict和tuple等,并对其中的的数据进行去重操作。 字符串做参数:>>> ss = set('python')>>> ssset(['h', 'o', 'n', 'p', 't', 'y'])list做参数:>>> s1 = set([7,6,5,4])>>> s1

2017-07-04 15:46:04 464

原创 Python,dict数据类型

本人所用的Python版本为:2.7.13 dict数据类型是键-值对,即key-value。可以根据键(key)查找到对应的值(value)。dict数据类型定义是用大括号”{}”来定义的。 1、添加数据 在初始化时就向dict中添加数据,比如:d={'tom':97,'mike':99};另外在初始化完成后,还可以通过键(key)放入,若dict中没有该键(value),则表示向该di

2017-07-04 15:17:03 744

原创 python,tuple数据类型

本人所用的python版本为:2.7.13 1、tuple(元组) tuple是另一种有序列表,差别在于tuple中的元素不能更改,因此没有相应的方法,比如:append()方法和insert()方法,来修改tuple中的元素。可以通过和list相应的方法来访问tuple中的元素。定义tuple可以通过小括号”()”来定义,并且在定义的时候就必须将tuple中的元素确定下来。如果tuple中只有

2017-07-04 14:56:26 2118

原创 Python ,list数据集合

本人所用的python版本为 2.7.13 1、list list用一种有序的数据集合,本人所理解的“有序的数据“是集合里的数据是按照添加顺序输出的,以前以为是自动排序,发现不是这样子的。list用中括号来定义”[]”,中间的数据用逗号来分割。 关于list的有些操作: (1)len(listName)获得list列表的元素个数 (2)访问listName。listName

2017-07-04 10:45:54 747

原创 Python 运行方式

Python运行方式有两种:通过python命令和直接运行python文件 1、通过python命令 编写正确的python程序,例如hello.py,保存在桌面上。打开Mac命令行,在命令行中改变路径到hello.py所在的目录,最后在命令行中输入 python hello.py,即可运行python程序。其中python为一条命令,表示运行python程序,紧跟在后面就是要运行的程序

2017-07-02 23:22:26 3355

翻译 1107. Social Clusters (30)

题目详情:https://www.patest.cn/contests/pat-a-practise/1107提交: 提交代码:#include <iostream>#include <vector>#include <algorithm>using namespace std;#define N 1010int hobby[N],likePerson[N];int n,isRoot[

2017-04-19 16:01:02 336

原创 1066. Root of AVL Tree (25)

题目详情:https://www.patest.cn/contests/pat-a-practise/1066提交:代码:#include <iostream>#include <malloc.h>using namespace std;#define N 22int n,number[N];typedef struct AVL{ int data,height; //heigh

2017-04-19 11:53:23 337

原创 1099. Build A Binary Search Tree (30)

题目详情: https://www.patest.cn/contests/pat-a-practise/1099提交:提交代码:#include <iostream>#include <algorithm>using namespace std;#define N 110typedef struct Node{ int data; int leftChild; in

2017-04-18 16:28:21 360

翻译 1064. Complete Binary Search Tree (30)

题目详情:https://www.patest.cn/contests/pat-a-practise/1064提交:代码:#include <iostream>#include <algorithm>using namespace std;#define N 1010int n,number[N],CBT[N],index = -1;void inOrder( int root ){

2017-04-18 15:10:17 435

原创 1043. Is It a Binary Search Tree (25)

题目详情:https://www.patest.cn/contests/pat-a-practise/1043提交: 提交代码:#include <iostream>#include <malloc.h>#include <vector>using namespace std;#define N 1010typedef struct BTree{ int data; s

2017-04-17 21:07:12 337

原创 1053. Path of Equal Weight (30)

题目详情:https://www.patest.cn/contests/pat-a-practise/1053提交: 提交代码:#include <iostream>#include <string.h>#include <vector>#include <algorithm>using namespace std;#define N 110#define INF 0x3f3f3f3f

2017-04-17 13:36:15 345

原创 1004. Counting Leaves (30)

题目详情:https://www.patest.cn/contests/pat-a-practise/1004提交情况:#include <iostream>#include <vector>#include <string.h>using namespace std;#define N 110vector<int> child[N];int n,m,Levels[N],maxLevel

2017-04-17 10:39:11 241

原创 1106. Lowest Price in Supply Chain (25)

题目详情:https://www.patest.cn/contests/pat-a-practise/1106提交情况:提交代码:#include <iostream>#include <string.h>#include <vector>#include <math.h>using namespace std;#define Max 100010#define INF 0x3f3f3f

2017-04-16 11:40:01 384

原创 1094. The Largest Generation (25)

题目详情:https://www.patest.cn/contests/pat-a-practise/1094提交情况: 提交代码:#include <iostream>#include <vector>using namespace std;#define Max 110int n,m,level[Max],maxLevel,visit[Max]; //level[Max]记录各节点的

2017-04-16 11:21:51 333

原创 1079. Total Sales of Supply Chain (25)

题目详情:https://www.patest.cn/contests/pat-a-practise/1079提交情况:代码:#include <iostream>#include <vector>#include <math.h> using namespace std;#define Max 100010//depths[]存储各节点的深度 //isRoot[]存储各个节点是否为根节

2017-04-16 09:54:48 355

原创 1090. Highest Price in Supply Chain (25)

题目信息: https://www.patest.cn/contests/pat-a-practise/1090提交情况: 提交代码:#include <iostream>#include <string.h>#include <vector>#include <math.h>#define Max 100010using namespace std;vector<int> child

2017-04-15 11:42:31 273

原创 1102. Invert a Binary Tree (25)

提交情况:代码:#include <iostream>#include <vector>#include <string.h>using namespace std;#define N 11typedef struct Node { int leftChild; int rightChild;}Node;Node node[N];int n,root[N];vec

2017-04-15 10:42:18 272

原创 1086. Tree Traversals Again (25)

提交情况:代码:#include <iostream>#include <string>#include <vector>#include <malloc.h>using namespace std;#define N 33#define INF 0x3f3f3f3fint number[N],top = -1,count,n;vector<int> num;typedef str

2017-04-14 15:41:55 359

原创 1020. Tree Traversals (25)

题目信息:https://www.patest.cn/contests/pat-a-practise/1020提交情况:代码:#include <iostream>#include <malloc.h>#include <vector>using namespace std;#define N 33typedef struct BTree{ int data; struc

2017-04-14 11:24:27 253

原创 1030. Travel Plan (30)

提交情况:代码:#include <iostream>#include <string.h>using namespace std;#define Max 505#define INF 0x3f3f3f3ftypedef struct Node{ int length; int cost;}Node;Node Graph[Max][Max];int n,m,s,d;

2017-04-14 10:02:18 326

原创 1018. Public Bike Management (30)

这里写代码片

2017-04-13 17:13:41 353

原创 1003. Emergency (25)

提交情况: #include <iostream>#include <string.h>using namespace std;#define Max 510#define INF 0x3f3f3f3f //Graph为邻接矩阵存储图,weight为点权,w记录最短路径上的点权之和 int Graph[Max][Max],weight[Max],w[Max];//visit为访问数组

2017-04-09 12:42:29 392

原创 1076. Forwards on Weibo (30)

#include <iostream>#include <vector>#include <string.h> #define Max 1010using namespace std;vector<int> Graph[Max]; //用邻接表存储图 int queue[Max],front,rear; //队列

2017-04-08 17:39:30 268

原创 1034. Head of a Gang (30)

#include <iostream>#include <string>#include <map>using namespace std;#define Max 2010 //一开始我把Max定义为1010结果出现了段错误。后来突然想到n条通话记录最多可以有2*n个人进行通话。 //所以需要把Max设置为2000以上 map<string,int>

2017-04-08 11:30:04 280

原创 1021. Deepest Root (25)

算法思想:用并查集取得连通分量的个数。然后把每个节点都分别作为根节点,求得该节点作为根的树高 ,并保存在数组中。最后输出。 #include <iostream>#include <vector>#include <string.h>#include <algorithm>using namespace std;#define Max 10002vector<int> G[Max];

2017-04-07 15:45:21 268

原创 1013. Battle Over Cities (25)

#include <iostream>#include <string.h>using namespace std;#define MAX 1010int graph[MAX][MAX]; //邻接矩阵用于存储图 int check[MAX],visit[MAX],key,n,m,k;void DFS( int start );int main (){ int a,b;

2017-04-06 14:34:44 298

原创 1098. Insertion or Heap Sort (25)

只有部分正确,苦思凝想也没弄清楚剩下的那两分是什么地方没有考虑到,欢迎各位大神指点! #include <iostream>using namespace std;#define N 110int num[N],pSorted[N],n,hnum[N];bool isSame(int a[],int b[]){ for(int i=1;i<=n;++i) {

2017-04-04 11:53:57 407

原创 1001. A+B Format (20)

#include <iostream>using namespace std;int main (){ int a,b; int stack[10],top = -1; while(scanf("%d%d",&a,&b)!=EOF) { top = -1; int sum = a+b,count = 0; int

2017-04-01 11:34:56 453

原创 Spring,Spring MVC和Mybatis集成

Spring和Spring MVC是天然集成在一起的。在web.xml中配置一个分发控制器

2017-03-27 11:34:03 763

原创 Chain the Ropes

题目描述:https://www.patest.cn/contests/pat-a-practise/1125#include <iostream>#include <algorithm>using namespace std;#define MAX 10010int main (){ int n,i; int j; double num[MAX]; cin

2017-03-07 21:19:58 580

原创 Raffle for Weibo Followers

题目描述:https://www.patest.cn/contests/pat-a-practise/1124/**明确题意:是从获奖的那个人开始的第n个人为下一个获奖的人。要不这么理解本题的难度就要加大。*/#include <iostream>#include <string.h>using namespace std;#define MAX 1010#define N 22ty

2017-03-07 19:53:58 318

原创 约瑟夫环问题

#include <iostream>#include <malloc.h>using namespace std;typedef struct Node{ int data; struct Node* next;}Node;int main (){ int n,m,count,length; cin>>n>>m; //建表前的初始化 N

2017-03-06 16:28:59 403

原创 前缀表达式

这是我根据这篇博客(http://blog.csdn.net/antineutrino/article/details/6763722/)中的思路写出的代码.原题目如下,但是个人认为二叉树的先序遍历结果对应着前缀表达式,个人猜测,如有牛人知道,欢迎赐教!若程序有不严谨的地方,欢迎指正!//编写程序:输入表达式,输出相应二叉树的先序遍历结果//输入:a+b*(c-d)-e/f//输出:-

2017-03-05 17:31:26 589

原创 一般算术表达式转换成后缀式

/**1、当操作符栈为空的时候,直接将操作符入栈处理。2、操作符不为空的时候,将要进栈的元素x与栈顶元素y比较优先级。若要进栈的元素x优先级较高,则直接进栈;   若栈顶的元素较高,则先将栈顶元素输出,再将进栈元素进栈。3、若遇到左括号(,则直接将其进栈,并其优先级最低,这样便于括号内的操作符进栈。*/#include #include #include usi

2017-03-01 13:49:17 1763

原创 Maven构建web工程目录结构

以上是Maven建立的web工程目录结构src/main/java文件夹下是放置java源文件的地方,

2015-12-18 16:22:42 890

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除