关闭

哈希(5)

原题: /** * Created by gouthamvidyapradhan on 25/03/2017. * Given a string, sort it in decreasing order based on the frequency of characters. * * Example 1: * * Input: * "tree" * * O...
阅读(13) 评论(0)

哈希(4)

原题:/** * Created by gouthamvidyapradhan on 18/10/2017. * Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't * one, return 0 instead. Note:...
阅读(14) 评论(0)

哈希(3)

原题:/** * Created by gouthamvidyapradhan on 28/03/2017. * Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as...
阅读(14) 评论(0)

哈希(2)

原题:/** * Created by gouthamvidyapradhan on 10/03/2017. * Given an array of strings, group anagrams together. * * For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], * Return: * <p...
阅读(13) 评论(0)

哈希(1)

原题:/** * Created by gouthamvidyapradhan on 25/02/2017. * Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. * * Strings consists of lowercase English le...
阅读(6) 评论(0)

贪心算法(6)

原题: /** * Created by gouthamvidyapradhan on 29/06/2017. * Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the heigh...
阅读(5) 评论(0)

贪心算法(5)

原题: /** * Created by gouthamvidyapradhan on 28/06/2017. * Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlappi...
阅读(5) 评论(0)

贪心算法(4)

原题: /** * Created by gouthamvidyapradhan on 02/04/2017. * Given an array of non-negative integers, you are initially positioned at the first index of the array. * * Each element in the array r...
阅读(2) 评论(0)

贪心算法(3)

原题:/** * Created by gouthamvidyapradhan on 17/03/2017. * Given an array of non-negative integers, you are initially positioned at the first index of the array. * * Each element in the array rep...
阅读(2) 评论(0)

贪心算法(2)

原题:/** * Created by gouthamvidyapradhan on 28/06/2017. * There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. * * You have a car with an unlimited ga...
阅读(3) 评论(0)

贪心算法(1)

原题: /** * Created by gouthamvidyapradhan on 27/06/2017. * * There are n different online courses numbered from 1 to n. Each course has some duration(course length) t and closed on dth day. A cou...
阅读(19) 评论(0)

java算法(11)

原题:/** * Created by gouthamvidyapradhan on 28/06/2017. * * There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordin...
阅读(20) 评论(0)

设计模式之访问者模式

访问者模式可以在不同的操作时不需要修改原来的接口 /** * Created by gmy on 2017/10/20. */ public class App { public static void main(String[] args) { Commander commander = new Commander(new Sergea...
阅读(28) 评论(0)

设计模式之孪生兄弟

当你开启一个进程,你点击时停止这个进程。再点击时开启这个进程public class App { public static void main(String[] args) throws InterruptedException { BallItem ballItem=new BallItem(); BallThread ballThread=new Bal...
阅读(34) 评论(0)

设计模式之状态

状态模式:无非就是状态的改变 public class App { public static void main(String[] args) { Mammoth mammoth=new Mammoth(); mammoth.observe(); mammoth.timePasses(); mammoth.observe()...
阅读(18) 评论(0)

设计模式之模板方法

跟策略方法类似,就是换方法public class App { public static void main(String[] args) { HalflingThief thief=new HalflingThief(new HitAndRunMethod()); thief.steal(); thief.changeMethod(new...
阅读(27) 评论(0)

线程池的运用

当有很多线程的时候就可以用到线程池了 ExecutorService executor = Executors.newFixedThreadPool(3);这是创建3个固定的线程池,如果线程有4个,则另一个只能处于等待状态public class App { public static void main(String[] args) { List tasks =...
阅读(18) 评论(0)

动态规划(20)

原题: /** * Created by gouthamvidyapradhan on 31/03/2017. * Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. * * For example, * Given n...
阅读(14) 评论(0)

动态规划(19)

原题: /** * Created by gouthamvidyapradhan on 31/03/2017. * Given n, how many structurally unique BST's (binary search trees) that store values 1...n? * * For example, * Given n = 3, there are...
阅读(13) 评论(0)

动态规划(18)

原题: /** * Created by gouthamvidyapradhan on 07/04/2017. * Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where...
阅读(21) 评论(0)
117条 共6页1 2 3 4 5 ... 下一页 尾页
    个人资料
    • 访问:3557次
    • 积分:1182
    • 等级:
    • 排名:千里之外
    • 原创:116篇
    • 转载:0篇
    • 译文:1篇
    • 评论:0条
    文章分类
    文章存档