算法
v_v...
这个作者很懒,什么都没留下…
展开
-
字符数组-竖式问题
竖式问题:找出所有形如abc*de(三位数乘以两位数)的算式,使得在完整的竖式中,所有数字都属于一个特定的数字集合(也就是a b c d e 以及abc*e abc*d abc*de结果的每一位数字都属于一个集合)。下面你输入数字集合(相邻数字之间没有空格),输出所有竖式。每个竖式前应有编号,之后应有一个空行。最后输出解的总数,下面是输入输出样例(为了便于观察,竖式中的空格改用小数点显示,但所...原创 2018-07-24 20:02:29 · 270 阅读 · 0 评论 -
数组与字符串 -- 颠倒单词的出现顺序
原创 2018-09-10 10:57:17 · 477 阅读 · 0 评论 -
LeetCode ---204. Count Primes
Count the number of prime numbers less than a non-negative number, n.Example:Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.思路:利用厄拉多塞筛法。具体操作:先将 ...转载 2018-09-09 22:22:09 · 156 阅读 · 0 评论 -
LeetCode.189 Rotate Array
Given 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,2,3,4]Explanation:rotate 1 steps to the right: [7,1...原创 2018-09-05 09:29:53 · 192 阅读 · 0 评论 -
136. Single Number
Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without us...原创 2018-08-25 16:31:01 · 113 阅读 · 0 评论 -
125 Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid palindrome.Examp...原创 2018-08-25 15:45:01 · 147 阅读 · 0 评论 -
LeetCode 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note: A leaf is a node with no children.Example:...原创 2018-08-13 17:05:08 · 137 阅读 · 0 评论 -
LeetCode 111. Minimum Depth of Binary
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note: A leaf is a node with no childre...原创 2018-08-13 16:39:09 · 141 阅读 · 0 评论 -
LeetCode 110 Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never diff...原创 2018-08-13 11:38:46 · 141 阅读 · 0 评论 -
LeetCode 101. Symmetric Tree (对称二叉树) 108. Convert Sorted Array To BST(二叉搜索树)
101. Symmetric Tree (对称二叉树)Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \...原创 2018-08-13 11:15:37 · 117 阅读 · 0 评论 -
LeetCode 107.Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,15,7...原创 2018-08-12 18:08:29 · 136 阅读 · 0 评论 -
数组-猜数字游戏的提示
猜数字游戏的提示: 实现一个经典“猜数字”游戏。给定答案序列和用户猜的序列,统计有多少数字位置正确(A),有多少数字在两个序列都出现过但位置不对(B)输入包含多组数据。每组输入第一行为序列长度n,第二行是答案序列,接下来是若干猜测序列。猜测序列全0时该数组数据结束。n=0时输入结束。样例输入41 3 5 51 1 2 30 0 0 0101 2 2 2 4 5...原创 2018-07-24 20:56:33 · 562 阅读 · 0 评论 -
234. Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: trueFollow up:Could you do it in O(n) time a...原创 2018-09-23 10:29:24 · 187 阅读 · 0 评论