算法
成长中的小黄人
这个作者很懒,什么都没留下…
展开
-
二叉搜索树的后序遍历序列(剑指offer)
二叉搜索树的后序遍历序列原创 2016-06-24 11:55:54 · 244 阅读 · 0 评论 -
maximal-rectangle
求给出的二维数组里面矩阵全为1的最大矩阵。 Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones and return its area.借助求柱形图的最大范围。public class Solution { public int maximalRec原创 2016-09-01 11:06:34 · 303 阅读 · 0 评论 -
蘑菇街笔试题总结
修理桌子 Arthur最近搬到了新的别墅,别墅特别大,原先的桌子显得比较小,所以他决定换一张新的桌子。他买了一张特别大的桌子,桌子是由很多条桌腿进行支撑的,可是回到家之后他发现桌子不稳,原来是桌子腿长度不太相同。他想要自己把桌子修理好,所以他决定移除掉一些桌腿来让桌子变得平稳。桌子腿总共有n条腿,第i条腿长度为li,Arthur移除第i桌腿要花费代价为di。假设k条腿桌子平稳的条件:超过一半桌腿能原创 2016-07-25 14:36:57 · 851 阅读 · 0 评论 -
decode-ways(动态规划)
A message containing letters fromA-Zis being encoded to numbers using the following mapping:‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26Given an encoded message containing digits, determine the total number of way原创 2016-08-05 08:33:20 · 316 阅读 · 0 评论 -
leetcode(word-break)
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s =”leetcode”, dict =[“leet”, “co原创 2016-06-21 14:19:53 · 332 阅读 · 0 评论 -
leetcode(palindrome-partitioning-ii)
Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s =”aab”, Return1since翻译 2016-06-17 14:54:19 · 301 阅读 · 0 评论 -
leetcode(valid-palindrome)判断字符串是否是对称
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, “A man, a plan, a canal: Panama”is a palindrome. “race a car”is not a palindr转载 2016-07-06 20:22:03 · 641 阅读 · 0 评论 -
美团实习生试题1
请设计一个算法,给一个字符串进行二进制编码,使得编码后字符串的长度最短。import java.util.*;import java.util.Map.Entry;public class lessStep { public static class Words implements Comparable{ public Words(Integer count){原创 2016-07-12 23:48:31 · 460 阅读 · 0 评论 -
序列化二叉树leetcode
system/core/healthd目录下的healthd.cpp保存命令的初始化位置,首先读取sys/class/power_supply目录下的所有文件,根据各目录下type的值得到PowerSupplyType的值。 struct sysfsStringEnumMap supplyTypeMap[] = { { “Unknown”, ANDROID_POWER_S原创 2016-06-27 13:53:21 · 328 阅读 · 0 评论 -
短作业优先调度算法
短作业优先(SJF, Shortest Job First)又称为“短进程优先”SPN(Shortest Process Next);是对FCFS算法的改进,其目标是减少平均周转时间。 短作业优先调度算法基于这样一种思想: 运行时间短的优先调度; 如果运行时间相同则调度最先发起请求的进程。 等待时间:一个进程从发起请求到开始执行的时间间隔。 现在有n个进程请求cpu,每个进程用一个二元组表原创 2016-07-11 19:07:18 · 14986 阅读 · 0 评论 -
leetcode(复制无向图)
题目描述 Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors. OJ’s undirected graph serialization: Nodes are labeled uniquely. We use#as a separator for each nod翻译 2016-06-13 16:33:17 · 531 阅读 · 0 评论 -
candy(litecode动态规划)
public class Solution { /* 从前往后遍历的过程中,如果后面一个元素比前面的大,则在前面的基础上加1,如果后面的元素比前面的小,则让其等于1. 从后往前遍历和从前往后遍历的过程一样。 */ public int candy(int[] ratings) { int[] candies=new int[rati原创 2016-06-13 14:19:51 · 643 阅读 · 0 评论 -
数组中的逆序对(剑指offer)
在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数。 public class Solution { public int InversePairs(int [] array) { if(array==null|array.length==0) return 0; int[] ret=ne原创 2016-06-24 15:31:26 · 317 阅读 · 0 评论 -
输出前n个数组合成的第k个数
The set[1,2,3,…,n]contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3):"123""132""213""231""312""32转载 2016-09-02 09:45:40 · 452 阅读 · 0 评论