
算法类
v_v...
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
字符数组-竖式问题
竖式问题: 找出所有形如abc*de(三位数乘以两位数)的算式,使得在完整的竖式中,所有数字都属于一个特定的数字集合(也就是a b c d e 以及abc*e abc*d abc*de结果的每一位数字都属于一个集合)。下面你输入数字集合(相邻数字之间没有空格),输出所有竖式。每个竖式前应有编号,之后应有一个空行。最后输出解的总数,下面是输入输出样例(为了便于观察,竖式中的空格改用小数点显示,但所...原创 2018-07-24 20:02:29 · 293 阅读 · 0 评论 -
121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock),...原创 2018-08-25 10:06:02 · 138 阅读 · 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 · 163 阅读 · 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 · 130 阅读 · 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 = 3 Output: [5,6,7,1,2,3,4] Explanation: rotate 1 steps to the right: [7,1...原创 2018-09-05 09:29:53 · 215 阅读 · 0 评论 -
LeetCode 198. House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house...原创 2018-09-08 20:47:40 · 188 阅读 · 0 评论 -
LeetCode ---202. Happy Number
Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares o...原创 2018-09-09 21:14:06 · 203 阅读 · 0 评论 -
LeetCode 205. Isomorphic Strings
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another ...原创 2018-09-16 10:17:09 · 193 阅读 · 0 评论 -
LeetCode 206. Reverse Linked List
Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL Follow up: A linked list can be reversed either iteratively or recursi...原创 2018-09-16 10:46:23 · 191 阅读 · 0 评论 -
数组与字符串--- 整数/字符串之间的转换
sscanf函数: sscanf函数原型为int sscanf(const char *str, const char *format, ...)。将参数str的字符串根据参数format字符串来转换并格式化数据,转换后的结果存于对应的参数内。具体功能如下: (1)根据格式从字符串中提取数据。如从字符串中取出整数、浮点数和字符串等。 (2)取指定长度的字符串 ...原创 2018-09-10 12:11:08 · 1117 阅读 · 0 评论 -
LeetCode 225. Implement Stack using Queues && 232. Implement Queue using Stacks
LeetCode 225. Implement Stack using Queues Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top()...原创 2018-09-19 18:10:01 · 244 阅读 · 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 · 156 阅读 · 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 · 160 阅读 · 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 · 160 阅读 · 0 评论 -
函数与递归-信息解码问题
问题描述: 考虑下面的01串序列: 0,00,01,10,000,001,010,011,100,101,110,0000,0001,....,1101,1110,00000.... 首先是长度为1的 串,然后是长度为2的串,以此类推。如果看成二进制,相同长度的后一个串等于前一个串加1.上述序列不存在全为1的串。 我们的任务是编写一个解码程序。 首先输入一个编码头 AB#TAN 则根...原创 2018-07-25 13:04:15 · 416 阅读 · 0 评论 -
KMP算法初解及代码
假设有字符串s1和字符串s2,长度分别为n和m。在求解s2是否为s1的子串这个问题中,可称s1是匹配串,称s2为模式串。KMP算法是一个复杂度为O(n+m)的算法。 在KMP算法中,有很多定义next数组的方式,并文介绍其中一种。 next数组采用以下定义。若next[j]==k,则k满足以下条件的最大值;s2[0..k-1]与s2[j-k..j-1]相同,且s2[k]...原创 2018-07-16 09:36:54 · 223 阅读 · 2 评论 -
LeetCode - Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dea...原创 2018-08-06 15:16:58 · 129 阅读 · 0 评论 -
LeetCode 67 - Add Binary
Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0. Example 1: Input: a = "11", b = "1" Output: "100" Exam...转载 2018-08-11 10:36:41 · 164 阅读 · 0 评论 -
LeetCode-69 Sqrt(x)
Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only...原创 2018-08-11 11:31:51 · 212 阅读 · 0 评论 -
LeetCode - 70 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 can you climb to the top? Note: Given n will be a positive...原创 2018-08-11 17:24:38 · 142 阅读 · 0 评论 -
LeetCode 88 Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume tha...原创 2018-08-11 21:44:06 · 117 阅读 · 0 评论 -
LeetCode - Same Tree 100
Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. Example ...原创 2018-08-12 12:01:55 · 220 阅读 · 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 · 158 阅读 · 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 · 133 阅读 · 0 评论 -
234. Palindrome Linked List
Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) time a...原创 2018-09-23 10:29:24 · 205 阅读 · 0 评论