
Java学习
文章平均质量分 84
xiaoqiangsun
sunbq011@gmail.com
展开
-
PAT-1073. Scientific Notation(Java StringBuild)
其实这篇也是PAT的题目,不过主要是用来学习Java字符串的操作的。今天看了Java编程思想字符串的章节,原来java里面String对象是永远不会变的,因为没有任何方法是修改字符串里面的数据的。如果要操作字符串对象例如:String str = "de";String s = "abc" + str + "fgh" + "00"; 理论上讲,第二个操作在执行过程中,每执行一次加原创 2014-03-13 23:16:08 · 1443 阅读 · 0 评论 -
PAT-1075. PAT Judge
最近在学习JAVA,用题目练习一下,这道题目还是没有pass,一个case不行,一个case运行超时。主要学习的是复杂问题构造类的思路,另外是Comparator类的学习,如何将一个list进行sort。The ranklist of PAT is generated from the status list, which shows the scores of the sub原创 2014-03-13 22:52:51 · 710 阅读 · 0 评论 -
PAT-1072. Gas Station(DIJKSTRA)
Today I review the DIJSKRA algorithm. Which is used to get the shortest length of all nodes in a map.The first step is : to initial the result list 'res' and the sign list 'finRes', which marks whe原创 2014-03-16 17:46:08 · 1189 阅读 · 0 评论 -
PAT-1043. Is It a Binary Search Tree(BST java)
用英文描述一下思路吧...We are given a preorder list of tree, if it is a BST, then give the postorder list.I got some clue from the algorithm "how to get a tree from its preorder and inorder lists". It w原创 2014-03-15 17:16:47 · 946 阅读 · 0 评论 -
PAT-1002. A+B for Polynomials(Map)
Today I studied the concept of Map in Java.In Map is described as : a group of key-value object pairs, allowing you to look up a value using a key. The ability to map objects to other objects can b原创 2014-03-17 17:57:51 · 1022 阅读 · 0 评论 -
PAT-1004. Counting Leaves(Queue)
From this problem I learned that the how to traverse tree by level order.Here is the code of level traversal: Queue q = new LinkedList(); q.add(n); while (q.size() != 0) { n = q.poll();原创 2014-03-18 22:40:40 · 765 阅读 · 0 评论 -
PAT-1007. Maximum Subsequence Sum(最大连续子数列)
最大连续子数列的问题:用了递归的解法,n长度的数列,先求得n-1的最大子数列,那么最大子数列要么是包含第n个数的数列,或者是不包含n的n-1的最大子数列。Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ...,原创 2014-03-19 23:53:33 · 1215 阅读 · 0 评论 -
PAT-1008. Elevator
今天偷懒了,做了一道最简单的题目,,没什么好看得,但是应该是pass最快的一道题了。。为了证明今天做过了.....还是贴到这里来吧The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at原创 2014-03-20 23:43:18 · 608 阅读 · 0 评论