
算法学习
文章平均质量分 69
月盡天明
Hope is a good thing,maybe the best of things!
展开
-
英雄会-----倒水-----欧几里德算法
倒 水题目:有两个容器,容积分别为A升和B升,有无限多的水,现在需要C升水。我们还有一个足够大的水缸,足够容纳C升水。起初它是空的,我们只能往水缸里倒入水,而不能倒出。可以进行的操作是:把一个容器灌满;把一个容器清空(容器里剩余的水全部倒掉,或者倒入水缸);用一个容器的水倒入另外一个容器,直到倒出水的容器空或者倒入水的容器满。 问是否能够通原创 2014-02-07 16:28:56 · 2292 阅读 · 0 评论 -
【LeetCode】101. Symmetric Tree 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51471280Subject 出处:https://leetcode.com/problems/invert-binary-tree/ Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to原创 2016-05-30 23:06:35 · 10346 阅读 · 0 评论 -
【LeetCode】165. Compare Version Numbers 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51429823Subject 出处:https://leetcode.com/problems/compare-version-numbers/ Compare two version numbers version1 and version2. If version1原创 2016-05-17 21:18:12 · 6546 阅读 · 2 评论 -
【LeetCode】105. Construct Binary Tree from Preorder and Inorder Traversal 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51471280Subject 出处:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ Given preorder and inorder traversa原创 2016-06-01 23:42:08 · 8636 阅读 · 0 评论 -
【LeetCode】1. Two Sum 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51439523Subject 出处:https://leetcode.com/problems/two-sum/ Given an array of integers, return indices of the two numbers such that they add原创 2016-05-21 17:14:13 · 8837 阅读 · 0 评论 -
【LeetCode】257. Binary Tree Paths 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51471280Subject 出处:https://leetcode.com/problems/binary-tree-paths/Given a binary tree, return all root-to-leaf paths.For example, given the fo原创 2016-05-22 10:57:58 · 12659 阅读 · 2 评论 -
【LeetCode】144 . Binary Tree Preorder Traversal 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51471280Subject 出处:https://leetcode.com/problems/binary-tree-preorder-traversal/ Given a binary tree, return the preorder traversal of its node原创 2016-05-22 23:53:41 · 7143 阅读 · 0 评论 -
【LeetCode】94. Binary Tree Inorder Traversal 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51471280Subject 出处:https://leetcode.com/problems/binary-tree-inorder-traversal/Given a binary tree, return the inorder traversal of its nodes'原创 2016-05-22 23:59:26 · 10682 阅读 · 0 评论 -
【LeetCode】11. Container With Most Water 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51541984Subject 出处:https://leetcode.com/problems/container-with-most-water/ Given n non-negative integers a1, a2, …, an, where each represents原创 2016-07-04 14:56:36 · 5827 阅读 · 0 评论 -
【LeetCode】2. Add Two Numbers 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51820937Subject 出处:https://leetcode.com/problems/add-two-numbers/ You are given two linked lists representing two non-negative numbers. The dig原创 2016-10-24 19:46:34 · 9816 阅读 · 2 评论 -
【LeetCode】273. Integer to English Words 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51820937Subject 出处:https://leetcode.com/problems/integer-to-english-words/ Convert a non-negative integer to its english words representation.原创 2016-10-08 14:43:55 · 3859 阅读 · 0 评论 -
【LeetCode】189. Rotate Array
https://leetcode.com/problems/rotate-array/DescriptionGiven an array, rotate the array to the right by k steps, where k is non-negative.Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1...原创 2019-01-06 13:36:06 · 879 阅读 · 0 评论 -
【LeetCode】150. Evaluate Reverse Polish Notation
Subjecthttps://leetcode.com/problems/evaluate-reverse-polish-notation/Explainhttps://en.wikipedia.org/wiki/Reverse_Polish_notationReverse Polish Notation – RPN也就是 “逆波兰式” ,又称 “后缀表达式” 。如:我们平时写a+...原创 2019-01-07 08:59:56 · 671 阅读 · 0 评论 -
【LeetCode】100. Same Tree 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51471280Subject 出处:https://leetcode.com/problems/same-tree/ Given two binary trees, write a function to check if they are equal or not. Tw原创 2016-05-30 22:06:42 · 10058 阅读 · 0 评论 -
【LeetCode】345. Reverse Vowels of a String 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51416284Subject 出处:https://leetcode.com/problems/reverse-vowels-of-a-string/ Write a function that takes a string as input and reverse only原创 2016-05-16 23:57:49 · 8066 阅读 · 1 评论 -
【LeetCode】226. Invert Binary Tree 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51471280Subject 出处:https://leetcode.com/problems/invert-binary-tree/ Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to原创 2016-05-29 00:18:13 · 12806 阅读 · 4 评论 -
英雄会-----任意长度的两个正整数相乘
任意长度的两个正整数相乘题目: 两个大数相乘:char* multiply(char*,char*)。给了两个字符串,每个都是代表了一个很长的10进制表示的数, 比如 String str1 = "23456789009877666555544444"; String str2 = "346587436598437594375943875943875", 最后求出它们的乘积。原创 2014-02-08 10:13:51 · 3760 阅读 · 0 评论 -
英雄会-----报数游戏(3)
报数游戏(3)题目: 一种报数游戏是从1开始连续报数,如果报到7的倍数(7,14,21,28……)或者包含数字7的数(7,17,27,37……)就用拍手代替这个数而不能报出。假设你连续听到m声拍手,问造成你听到m声拍手的第一下拍手所代表的数是几?例如,你听到了两次连续的拍手,最小的可能这两次拍手是27和28,因此输出27。输入m, 输出这m次连续的拍手第一下所原创 2014-02-08 10:22:09 · 3782 阅读 · 5 评论 -
蓝桥杯-----世纪末的星期
世纪末的星期题目:曾有邪教称1999年12月31日是世界末日。当然该谣言已经不攻自破。还有人称今后的某个世纪末的12月31日,如果是星期一则会....有趣的是,任何一个世纪末的年份的12月31日都不可能是星期一!! 于是,“谣言制造商”又修改为星期日......1999年的12月31日是星期五,请问:未来哪一个离我们最近的一个世纪末年(即xx99年)的12月31日正好是星期原创 2014-02-08 23:24:54 · 5090 阅读 · 2 评论 -
幻方阵(魔方阵)
题目:n阶幻方阵,也叫魔方阵,是指将1~n*n个正整数排列成n x n阶方阵,n为奇数。它具有这样的性质:每行,每列,以及对角线之和都是相等的,都是n(n*n+1)/2。分析:用二维数组来存放次方阵。1. 将1放在第一行的中间位置。2. 连续的数字从坐下向右上的方向顺序放置,即下一个数的位置在当前位置的右上方。3. 将此方阵看成环形,规律如下:i = (i原创 2014-02-23 22:42:41 · 4620 阅读 · 0 评论 -
英雄会-----杨辉三角-----杨辉三角的变形
杨辉三角的变形杨辉三角杨辉三角大家都熟悉,二项式n次方展开式的系数可排列成一个三角形的数表,成为杨辉三角。形似:1 1 1 1 2 11 3 3 1输出杨辉三角的代码:import java.util.*;public class Yanghui{ public static void main(String args[]){原创 2014-02-24 01:09:20 · 4051 阅读 · 2 评论 -
【LeetCode】145. Binary Tree Postorder Traversal 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51471280Subject 出处:https://leetcode.com/problems/binary-tree-postorder-traversal/ Hard 级别Given a binary tree, return the postorder travers原创 2016-05-25 00:48:57 · 7100 阅读 · 0 评论 -
【LeetCode】102. Binary Tree Level Order Traversal 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51477967Subject 出处:https://leetcode.com/problems/binary-tree-level-order-traversal/Given a binary tree, return the level order traversal of its原创 2016-05-26 15:06:54 · 5073 阅读 · 1 评论 -
【LeetCode】107. Binary Tree Level Order Traversal II 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51477967Subject 出处:https://leetcode.com/problems/binary-tree-level-order-traversal-ii/Given a binary tree, return the bottom-up level order tra原创 2016-05-26 16:18:51 · 9739 阅读 · 1 评论 -
【LeetCode】54. Spiral Matrix 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/50771703Subject 出处:https://leetcode.com/problems/spiral-matrix/ Given a matrix of m x n elements (m rows, n columns), return all elements o原创 2016-05-15 10:28:27 · 7184 阅读 · 0 评论 -
【LeetCode】59. Spiral Matrix II 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51416037Subject 出处:https://leetcode.com/problems/spiral-matrix/ Given an integer n, generate a square matrix filled with elements from 1 to原创 2016-05-15 11:21:35 · 4593 阅读 · 1 评论 -
【LeetCode】103. Binary Tree Zigzag Level Order Traversal 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51471280Subject 出处:https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ Given a binary tree, return the zigzag level ord原创 2016-05-28 12:04:05 · 9485 阅读 · 0 评论 -
【LeetCode】344. Reverse String 解题报告
转载请注明出处:http://blog.youkuaiyun.com/crazy1235/article/details/51416284Subject 出处:https://leetcode.com/problems/reverse-string/ Write a function that takes a string as input and returns the string rever原创 2016-05-15 23:48:47 · 15576 阅读 · 2 评论 -
【LeetCode】205. Isomorphic Strings
Subjecthttps://leetcode.com/problems/isomorphic-strings/Explain判断两个字符串是否是”同构“字符串。Solution/** * HashMap * 25ms * * @param s * @param t * @return */ public boolean isIsomorphic(...原创 2019-01-08 12:44:46 · 809 阅读 · 0 评论