- 博客(12)
- 收藏
- 关注
原创 LeetCode 88 — Merge Sorted Array(C++ Java Python)
题目:http://oj.leetcode.com/problems/merge-sorted-array/Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is gr
2014-03-31 17:05:55 4136
原创 ZOJ 1879 — Jolly Jumpers(C++)
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1879分析: 计算相邻整数之间的差值,对结果进行排序,然后与1-(n-1)逐一比较,如有不同则返回Not jolly。C++实现:#include #include #include #include /* abs *
2014-03-22 15:06:43 1368
原创 ZOJ 2886 — Look and Say(C++)
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2886分析: 对于每一个字符串中的字符,判断是否与之前的字符相同,如相同则计数加1,否则输出计数和之前的字符,记录新字符并重新计数。注意for循环外要输出最后的计数及字符。C++实现:/*Sample Input31223441
2014-03-22 14:55:54 1030
原创 ZOJ 3758 — Singles' Day(C++)
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3758分析: 主要是转换成十进制以及素数的判断,要使用unsigned long long(或unsigned __int64),范围为[0, 2^64)。C++实现:/*Sample Input3 32 42 110
2014-03-22 14:44:49 898
原创 LeetCode 50 — Pow(x, n)(C++ Java Python)
题目:http://oj.leetcode.com/problems/powx-n/Implement pow(x, n).题目翻译: 实现pow(x,n)。分析: 二分。C++实现:class Solution {public: double pow(double x, int n) { if(n < 0)
2014-03-21 11:04:11 3720
原创 LeetCode 20 — Valid Parentheses(C++ Java Python)
题目:http://oj.leetcode.com/problems/valid-parentheses/Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close
2014-03-21 09:37:46 3832
原创 LeetCode 70 — Climbing Stairs(C++ Java Python)
题目:http://oj.leetcode.com/problems/climbing-stairs/You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways ca
2014-03-20 22:17:03 3784
原创 LeetCode 15 — 3Sum(C++ Java Python)
题目:http://oj.leetcode.com/problems/3sum/Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of ze
2014-03-20 21:22:02 5108 3
原创 LeetCode 144 — Binary Tree Preorder Traversal(C++ Java Python)
题目:http://oj.leetcode.com/problems/binary-tree-preorder-traversal/Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \
2014-03-02 22:13:14 3627 3
原创 LeetCode 148 — Sort List(C++ Java Python)
题目:http://oj.leetcode.com/problems/sort-list/Sort a linked list in O(n log n) time using constant space complexity.题目翻译:在O(nlogn)时间内,使用常数空间对链表进行排序。分析: 使用归并排序,复用Merge Two Sorted Lists代
2014-03-02 12:16:54 4524 1
原创 LeetCode 149 — Max Points on a Line(C++ Java Python)
题目:http://oj.leetcode.com/problems/max-points-on-a-line/Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.题目翻译:给定二维平面上的n个点,找出位于同一直线上的点的最大数目。分析:
2014-03-02 10:50:24 4722 2
原创 LeetCode 150 — Evaluate Reverse Polish Notation(C++ Java Python)
题目:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be
2014-03-01 15:34:39 3437 2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人