- 博客(290)
- 资源 (7)
- 收藏
- 关注
原创 两指针(7)
原题:/** * Created by gouthamvidyapradhan on 08/03/2017. * Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap a
2017-10-25 08:55:34 131
原创 两指针(6)
原题:/** * Created by gouthamvidyapradhan on 13/06/2017. * Accepted * Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the s
2017-10-25 08:55:10 145
原创 两指针(5)
原题:/** * Created by gouthamvidyapradhan on 29/03/2017. * Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the
2017-10-25 08:54:34 127
原创 两指针(4)
原题:/** * Created by gouthamvidyapradhan on 04/07/2017. * Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. * <p> * Do not alloc
2017-10-25 08:54:01 148
原创 两指针(3)
原题:/** * Created by gouthamvidyapradhan on 13/06/2017. * Accepted * Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elemen
2017-10-25 08:53:31 119
原创 两指针(2)
原题:/** * Created by gouthamvidyapradhan on 09/03/2017. * Given a string, find the length of the longest substring without repeating characters. * <p> * Examples: * <p> * Given "abcabcbb", the ans
2017-10-25 08:53:04 148
原创 两指针(1)
原题:/** * Created by gouthamvidyapradhan on 29/03/2017. * Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the ar
2017-10-25 08:52:33 148
原创 栈(4)
原题:/** * Created by gouthamvidyapradhan on 25/02/2017. * Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. * <p> * The brackets
2017-10-25 08:51:36 138
原创 栈(3)
原题:/** * Created by gouthamvidyapradhan on 29/07/2017. * Implement the following operations of a queue using stacks. * <p> * push(x) -- Push element x to the back of queue. * pop() -- Removes the
2017-10-25 08:51:03 152
原创 栈(2)
原题:/** * Created by gouthamvidyapradhan on 08/03/2017. * Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. * <p> * push(x) -- Push element x onto sta
2017-10-25 08:50:32 160
原创 栈(1)
原题:/** * Created by gouthamvidyapradhan on 20/06/2017. * Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in
2017-10-25 08:49:54 172
原创 哈希(7)
原题:/** * Created by gouthamvidyapradhan on 10/03/2017. * Given two strings s and t, write a function to determine if t is an anagram of s. * * For example, * s = "anagram", t = "nagaram", re
2017-10-24 11:18:06 225
原创 哈希(6)
原题:/** * Created by gouthamvidyapradhan on 09/03/2017. * Given an array of integers, return indices of the two numbers such that they add up to a specific target. * <p> * You may assume that each i
2017-10-24 11:17:34 182
原创 哈希(5)
原题:/** * Created by gouthamvidyapradhan on 25/03/2017. * Given a string, sort it in decreasing order based on the frequency of characters. * <p> * Example 1: * <p> * Input: * "tree" * <p> * O
2017-10-24 11:16:50 214
原创 哈希(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:
2017-10-24 11:16:19 237
原创 哈希(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
2017-10-24 11:15:49 217
原创 哈希(2)
原题:/** * Created by gouthamvidyapradhan on 10/03/2017. * Given an array of strings, group anagrams together. * <p> * For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], * Return: * <p
2017-10-24 11:15:20 206
原创 哈希(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. * <p> * Strings consists of lowercase English le
2017-10-24 11:14:45 149
原创 贪心算法(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
2017-10-21 15:53:17 188
原创 贪心算法(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
2017-10-21 15:52:50 135
原创 贪心算法(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
2017-10-21 15:52:14 122
原创 贪心算法(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. * <p> * Each element in the array rep
2017-10-21 15:51:31 134
原创 贪心算法(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]. * <p> * You have a car with an unlimited ga
2017-10-21 15:50:55 209
原创 贪心算法(1)
原题:/** * Created by gouthamvidyapradhan on 27/06/2017. * <p> * 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
2017-10-21 15:50:20 204
原创 java算法(11)
原题:/** * Created by gouthamvidyapradhan on 28/06/2017. * <p> * There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordin
2017-10-21 15:49:32 160
原创 设计模式之访问者模式
访问者模式可以在不同的操作时不需要修改原来的接口 /** * Created by gmy on 2017/10/20. */public class App { public static void main(String[] args) { Commander commander = new Commander(new Sergea
2017-10-20 10:38:14 153
原创 设计模式之孪生兄弟
当你开启一个进程,你点击时停止这个进程。再点击时开启这个进程public class App { public static void main(String[] args) throws InterruptedException { BallItem ballItem=new BallItem(); BallThread ballThread=new Bal
2017-10-20 09:58:55 425
原创 设计模式之状态
状态模式:无非就是状态的改变 public class App { public static void main(String[] args) { Mammoth mammoth=new Mammoth(); mammoth.observe(); mammoth.timePasses(); mammoth.observe()
2017-10-20 09:32:49 136
原创 设计模式之模板方法
跟策略方法类似,就是换方法public class App { public static void main(String[] args) { HalflingThief thief=new HalflingThief(new HitAndRunMethod()); thief.steal(); thief.changeMethod(new
2017-10-20 09:12:15 191
原创 线程池的运用
当有很多线程的时候就可以用到线程池了 ExecutorService executor = Executors.newFixedThreadPool(3);这是创建3个固定的线程池,如果线程有4个,则另一个只能处于等待状态public class App { public static void main(String[] args) { List<Task> tasks =
2017-10-20 08:42:26 171
原创 动态规划(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
2017-10-19 09:46:46 181
原创 动态规划(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
2017-10-19 09:46:14 136
原创 动态规划(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
2017-10-19 09:45:44 156
原创 动态规划(17)
原题:/** * Created by gouthamvidyapradhan on 19/08/2017. * Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: * * Copy All:
2017-10-19 09:45:02 176
原创 动态规划(16)
原题:/** * Created by pradhang on 4/3/2017. * Given a string s, partition s such that every substring of the partition is a palindrome. * * Return the minimum cuts needed for a palindrome parti
2017-10-19 09:44:35 134
原创 动态规划(15)
原题:/** * Created by gouthamvidyapradhan on 07/07/2017. * Find the contiguous subarray within an array (containing at least one number) which has the largest sum. * * For example, given the ar
2017-10-19 09:43:58 146
原创 动态规划(14)
原题:/** * Created by gouthamvidyapradhan on 02/04/2017. * Find the contiguous subarray within an array (containing at least one number) which has the largest product. * * For example, given t
2017-10-19 09:43:34 142
原创 动态规划(13)
原题:/** * Created by gouthamvidyapradhan on 27/03/2017. * Given an unsorted array of integers, find the length of longest increasing subsequence. * * For example, * Given [10, 9, 2, 5, 3, 7,
2017-10-19 09:43:03 124
原创 动态规划(12)
原题:/** * Created by gouthamvidyapradhan on 24/02/2017. * Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. * * Example: *
2017-10-19 09:42:38 157
原创 动态规划(11)
原题:/** * Created by gouthamvidyapradhan on 02/04/2017. * Given an unsorted array of integers, find the length of longest increasing subsequence. * * For example, * Given [10, 9, 2, 5, 3, 7,
2017-10-19 09:41:59 171
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人