由买买提看人间百态

topics

全部话题 - 话题: integate
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
s******r
发帖数: 5
1
来自主题: Computation版 - 谁熟悉cplex的integer programming
我是第一次用CPLEX,想用它来作一个integer linear programming
我的目标函数是 max(x1+x2+x3+...x10)
constraints是以x1,...x10为变量的
现在我想让x1....x10以整数的方式取值,比如0,1,3,4等
我的问题是不知道怎么搞的,优化下来结果是x1,...x10成了一个个的
double数,like 0.5, 1.5, 0.0, 2.5 ....
有谁知道怎么样在CPlex里强制x1...x10为整数变量吗?
Thanks!
w******a
发帖数: 27
2
要解MILP ( mixed integer linear programming)问题,请问Matlab 有没有解这类问
题的toolbox, 或者第三方提供的免费软件包。
w******a
发帖数: 27
3
要解MILP ( mixed integer linear programming)问题,请问Matlab 有没有解这类问
题的toolbox, 或者第三方提供的免费软件包。
D*******a
发帖数: 3688
4
纯integer?试试cplex
A*******r
发帖数: 768
5
来自主题: Mathematics版 - 紧急求助!Stochastic Integer Programming
以我有限的经验来看
什么叫stochastic integer programming的global optimum?
m**********0
发帖数: 3
6
来自主题: Mathematics版 - about mixed integer linear programing
I have a question about mixed integer linear programing.
Give a MILP model IP(A,b,C,I) and a feasible solution xd of
this IP, how to get a new cost vector C* such that xd becomes
an optimal solution in IP(A,b,C*,I) ?
Any help will be appreciated.
thanks
Mar. 23 2009
y*****a
发帖数: 580
7
来自主题: Mathematics版 - Help on random integer generator
Thanks. That does not help. Let say N=5, as such I would a uniformly
distributed array, e.g.,
[5,2,3,1,4] where each integer between 1 and 5 appear once and only once.
If using randint, as far as I am reading, it seems that say [5,2,3,3,1] is
possible, 3 is appering twice while 4 is not appearing.
Thanks anyway.

思?
D**u
发帖数: 204
8
来自主题: Mathematics版 - Is there such a "measure" on integers?
I am wondering whether there exists such a "measure" F on ALL the subsets of the set of
integers, which satisfies the following conditions:
(1) F(S) = 0 for any finite subset S.
(2) F(S) can be negative.
(3) finite additivity: If S is the union of 2 disjoint subsets S1 and S2,
then F(S) = F(S1) + F(S2).
(4) non-triviality: F(S) != 0 for some S.
c****r
发帖数: 969
9
来自主题: Mathematics版 - if p(x) is ploynomial with integer cofficient
if p(x) is ploynomial with integer cofficient and p(sqrt(2))=0 then p(-sqrt(
2))=0
w******a
发帖数: 27
10
要解MILP ( mixed integer linear programming)问题,请问Matlab 有没有解这类问
题的toolbox, 或者第三方提供的免费软件包。
s*****g
发帖数: 77
11
来自主题: Quant版 - distribution of St=integal <0>W_sd_s?
请教大牛:
如果St= integal of W_sd_s from 0 to t, what is the distribution of St?
面试官英语太难听懂了,勉强明白这个意思。
e*****e
发帖数: 17
12
来自主题: Science版 - [转载] how do you do integer division?
去www.gnu.org,
有一个软件是做任意位数的integer运算... GPLed
w*****g
发帖数: 798
13
来自主题: Statistics版 - integer quadratic programming in R
有什么好的package?
我要做的事情是 min|Ax-Y| over x\in {0,1,2,...,n}^p
where A is a p by p matrix, Y is a p-dimentional vector and |.| is any type
of norm. Typically the choice of Euclidean norm reduces the problem to
integer quadratic programming.
我知道有个package叫Rcplex,但是安装不上。大家知道有什么办法解决这个问题,或者
别的package,或者怎么安装这个package.
多谢。
z*******n
发帖数: 1034
14
来自主题: MobileDevelopment版 - greater than a 32-bit integer
December 3, 2014 4:21 AM
Chris O'Brien
Add one more oddball milestone for the viral sensation “Gangnam Style.”
The song by PSY, the South Korean popmeister, has attracted so many views
that YouTube says it had to redesign its view counter to handle it.
In a post on its Google+ page, YouTube says:
“We never thought a video would be watched in numbers greater than a 32-bit
integer (=2,147,483,647 views), but that was before we met PSY. “Gangnam
Style” has been viewed so many times we have to upgra... 阅读全帖
g***s
发帖数: 3811
15
来自主题: JobHunting版 - 问道amazon的面试题
public class FindSegments {
public static void main(String args[]) throws InterruptedException {
// List segs = Arrays.asList(new Integer[]{2, 3, 5, 7,
8, 10});
List segs = Arrays.asList(new Integer[]
{2,2,4,6,7,7,8,8,8,9,9,10,11,12,13,14,15,16,16,17,18,20,21,22,23,24,25,2
6,28,
29,30,31,33,34,37,38,39,40,41,45,47,47,49,54,56});
long startTime = System.currentTimeMillis();
findSegs(segs);
System.out.printf("Total running time : %d ms",... 阅读全帖
g***s
发帖数: 3811
16
来自主题: JobHunting版 - 问道amazon的面试题
public class FindSegments {
public static void main(String args[]) throws InterruptedException {
// List segs = Arrays.asList(new Integer[]{2, 3, 5, 7,
8, 10});
List segs = Arrays.asList(new Integer[]
{2,2,4,6,7,7,8,8,8,9,9,10,11,12,13,14,15,16,16,17,18,20,21,22,23,24,25,2
6,28,
29,30,31,33,34,37,38,39,40,41,45,47,47,49,54,56});
long startTime = System.currentTimeMillis();
findSegs(segs);
System.out.printf("Total running time : %d ms",... 阅读全帖
c******1
发帖数: 37
17
来自主题: JobHunting版 - G家onsite 随机数一题
public class RandomBlack {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
RandomBlack fac = new RandomBlack();
List> lss = fac.permu(9);
for(List ls : lss) {
for(int i = 1; i < 10; i++) {
int getRan = fac.getRan(ls, i);
int check = fac.check(ls, i);
if(getRan == check) continue;
else {
Sys... 阅读全帖
b**l
发帖数: 51
18
or this, works on both 32-nit and 64-bit:
====
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.prefs.Preferences;
public class WinRegistry {
// inspired by
// http://javabyexample.wisdomplug.com/java-concepts/34-core-
java/62-java-registry-wrapper.html
// http://www.snipcode.org/java/1-java/23-java-class-for-accessing-
reading-and-writing-... 阅读全帖
d**********o
发帖数: 1321
19
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
hw3b c-.y file
上面这一楼贴了载止hw3b deadline时我match的结果(也就是老师可以以这些不match
的ERROR为借口不给后来我补上的成绩),但是因为当时我还是没有写完,后来感恩节
期间就接着又写了一些,而且hw5是based on hw3 & hw3b的基础上(当我hw5是based
on更好的hw3的结果时,我应该可以得更多的分吧)。
hw4因为写得比较顺利,就不曾保留任何交上去作业的output,没有什么一目了然的结
果是我可以贴在这里的。原本我是想要把自己最的一次作业hw5贴出来的,但那已经是
一个完整的compiler,而且以后我还需要用自己的course project来找工作,所以一定
就不贴最终结果了。那就贴一个hw3b的c-.y文件吧,它集中的hw1、hw2、hw3、 hw3b的
结果,是我自己hw3b *.y文件的最完整版本。这些作业里面也有很多机关一一人为增加
的难度,比如那六七个IO相关的function,不仅traverse tree、build syntax tree的
时候会成为一个考点(把它们作为一个node连在syntax... 阅读全帖
d**********o
发帖数: 1321
20
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
hw3b c-.y file
上面这一楼贴了载止hw3b deadline时我match的结果(也就是老师可以以这些不match
的ERROR为借口不给后来我补上的成绩),但是因为当时我还是没有写完,后来感恩节
期间就接着又写了一些,而且hw5是based on hw3 & hw3b的基础上(当我hw5是based
on更好的hw3的结果时,我应该可以得更多的分吧)。
hw4因为写得比较顺利,就不曾保留任何交上去作业的output,没有什么一目了然的结
果是我可以贴在这里的。原本我是想要把自己最的一次作业hw5贴出来的,但那已经是
一个完整的compiler,而且以后我还需要用自己的course project来找工作,所以一定
就不贴最终结果了。那就贴一个hw3b的c-.y文件吧,它集中的hw1、hw2、hw3、 hw3b的
结果,是我自己hw3b *.y文件的最完整版本。这些作业里面也有很多机关一一人为增加
的难度,比如那六七个IO相关的function,不仅traverse tree、build syntax tree的
时候会成为一个考点(把它们作为一个node连在syntax... 阅读全帖
x****y
发帖数: 252
21
以下是code面试题目,和我给的答案。答案有错,我标识了出来。请各位点评一下,进
一步提高!多谢!!!
面试管是印度人,
第一步,讨论解法:要求用实例,我给了 array (1,9,2,3,1,5,6,7,9,9) 和sum 10
,说用mapping hashmap,面试管表示明白了。第二步,面试管提出实例中的整数可能
有重复,我提出用第二个hash map :intCountsMap,解释其记录整数出现的次数,以
及使用。他表示不很理解,然后要求coding。
// Write a method that takes in two parameters (an array of integers and an
integer x). Print out the pairs of integers in the array that sum to x.
List> getSumPairs(List array, Integer
sum){
//Collections.sort(arra... 阅读全帖
D***0
发帖数: 138
22
来自主题: JobHunting版 - 发个evernote的code challenge
网上申请的,回复的挺快,安排了code challenge,一道题,不限时,半个小时写完了
,发过去,第二天收到了thank you but 88.不知道哪里的问题。
* Write a function that takes two parameters:
* (1) a String representing a text document and
* (2) an integer providing the number of items to return.
* Implement the function such that it returns a list of Strings ordered by
word frequency,
* the most frequently occurring word first.
* Use your best judgement to decide how words are separated.
* Your solution should run in O(n) time where n is the number of cha... 阅读全帖
t********n
发帖数: 611
23
来自主题: JobHunting版 - 为啥大家都说刷题无用呢
import java.util.HashMap;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.File;
import java.util.*;
public class Cluster4{
public static void main(String args[]) throws FileNotFoundException,
IOException{
long startTime = System.currentTimeMillis();
String line;
String path = "/Users/***/documents/java/coursera_2/week_2/
problem_2/clustering_big.txt";
File nodeFile = ne... 阅读全帖
S**I
发帖数: 15689
24
☆─────────────────────────────────────☆
gzou (gzou) 于 (Thu May 12 02:26:35 2011, 美东) 提到:
马上就要G on site了,
求祝福。
下面是从本版收集到的Google的试题,便于大家查询。
申明:有的附带有解释说明的,也来自于本版或者网络,大家自己看, 不保证真确
http://www.mitbbs.com/article_t1/JobHunting/31847453_0_1.html
本人ECE fresh PhD,背景是电路/EDA,跟G业务基本没什么关系
同学内部推荐的,很简单的一次电面就给了onsite
题都不难,但是自己没把握好机会,出了一些小bug。
总的感觉,出错就是硬伤,宁可从最简单的算法写起,也不能出错。
电面:
1,Skip list, http://en.wikipedia.org/wiki/Skip_list
写code实现struct skip_list * find(struct skip_list *head, int value)
2,sorted array... 阅读全帖
S**I
发帖数: 15689
25
☆─────────────────────────────────────☆
gzou (gzou) 于 (Thu May 12 02:26:35 2011, 美东) 提到:
马上就要G on site了,
求祝福。
下面是从本版收集到的Google的试题,便于大家查询。
申明:有的附带有解释说明的,也来自于本版或者网络,大家自己看, 不保证真确
http://www.mitbbs.com/article_t1/JobHunting/31847453_0_1.html
本人ECE fresh PhD,背景是电路/EDA,跟G业务基本没什么关系
同学内部推荐的,很简单的一次电面就给了onsite
题都不难,但是自己没把握好机会,出了一些小bug。
总的感觉,出错就是硬伤,宁可从最简单的算法写起,也不能出错。
电面:
1,Skip list, http://en.wikipedia.org/wiki/Skip_list
写code实现struct skip_list * find(struct skip_list *head, int value)
2,sorted array... 阅读全帖
c******b
发帖数: 13
26
public static List topK(int[] test,int k){
List l = new ArrayList();
if(k>test.length) return l;
//用hash存放股票名称,和出现次数
HashMap hash = new HashMap();
for(int i=0;i if(hash.containsKey(test[i])){
hash.put(test[i], hash.get(test[i])+1);
} else {
hash.put(test[i], 1);
}
}
//用一个priorityqueue,可以对出现次数进行排序... 阅读全帖
l**********n
发帖数: 8443
27
来自主题: Programming版 - java 8 也可以fp啊
package java8tests ;
import java.util.function.BiFunction ;
import java.util.function.Function ;
public class Currying {
public void currying() {
// Create a function that adds 2 integers
BiFunction adder = ( a, b ) -> a + b ;
// And a function that takes an integer and returns a function
Function> currier = a -> b ->
adder.apply( a, b ) ;
// Call apply 4 to currier (to get a function back)
... 阅读全帖
p*****2
发帖数: 21240
28
来自主题: JobHunting版 - 有些面试题是够扯蛋的
我觉得下边的代码更公平一些。
Sort used time (ms): 4657
HashMap Used time (ms): 1696
HashSet Used time (ms): 2433
public class test {
public int v1(Integer[] in) {
Integer[] a = new Integer[in.length];
System.arraycopy(in, 0, a, 0, in.length);
if (a.length == 0)
return 0;
Arrays.sort(a);
int ret = 1;
int start = 0;
int dup = 0;
for (int i = 1; i < a.length; i++) {
if (a[i] == a[i - 1] + 1) {
ret = Math.max(ret, i - start - dup + 1);
} else if (a[i] ... 阅读全帖
d******l
发帖数: 175
29
来自主题: JobHunting版 - 请教LeetCode的3Sum
大家好,我纠结这道题目一些时间了。期间用Java写了3个算法,在Judge Large的时候
都说超时。请教高人帮忙分析一下我的一个算法的复杂度(基于TwoSum的一个解法)。
非常感谢。
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class Solution {
public ArrayList> twoSum(int[] numbers, int target) {
ArrayList> twoSumList = new ArrayList Integer>>();
Map map = new HashMap();
for (in... 阅读全帖
e********3
发帖数: 18578
30
来自主题: JobHunting版 - 热腾腾g电面 已挂
BFS+DP,而且需要maintain两个距离,一个是到终点的最小距离,一个是到起点的最小
距离,计算终点的距离需要backtrack,到起点的简单比较保存最小值就行了,类似
Dijkstra算法。电面就考这个有点偏难了,尤其还是同胞就操蛋了,要是老中这么考老
印我绝对赞成。简单的实现还可以把障碍物那个的距离设成100啥的,这样自然就知道
要绕过了。
这个题目的难度比reverse linkedlist, atoi难了几个数量级。。。
我贴两个我自己写的代码抛砖引玉一下,第一个是Harry Potter最小的strength通关,
第二个是经典的Dijkstra algorithm,都是附带了测试数据自动生成的方法,你把这两
个组合一下基本就能解这道题了,过两天我有空了来写一下这道题的具体实现。
import java.util.*;
public class HarryPotter{
private static Random rand = new Random();
private static int[][] matrix;
private static ... 阅读全帖
p*****2
发帖数: 21240
31
来自主题: JobHunting版 - 有些面试题是够扯蛋的

代码都给你。你跑一个看看。
import java.io.Console;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
public class test {
public int v1(Integer[] in) {
Integer[] a = in;
//System.arraycopy(in, 0, a, 0, in.length);
if (a.length == 0)
return 0;
Arrays.sort(a);
int ret = 1;
int start = 0;
int dup = 0;
for (int i = 1; i < a.length; i++) {
if (a[i] == a[i - 1] + 1) {
ret = Math.max(ret... 阅读全帖
m*******t
发帖数: 1060
32
A simple solution as shown below.
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PathFinder {
private static void printPath(List path) {
for (int i = 0; i < path.size(); i++) {
System.out.format("%2d", path.get(i));
if (i != path.size() - 1)
System.out.print("->");
else
System.out.println();
}
}
private boolean shouldSkip(List阅读全帖
l****o
发帖数: 315
33
来自主题: JobHunting版 - 关于leetcode的combinationSum题
可过
public class Solution {
public ArrayList> combinationSum(int[] candidates,
int target) {
// Start typing your Java solution below
// DO NOT write main() function

Arrays.sort(candidates);
ArrayList>> f = new ArrayList >>();
for (int i = 0; i <= target; i++) {
ArrayList> tmp = new ArrayList Integer>>();
f.add(tmp);... 阅读全帖
S*******C
发帖数: 822
34
http://oj.leetcode.com/problems/subsets/
第一种格式:res作为局部变量避免线程安全问题,但比较啰嗦
public ArrayList> subsets(int[] num){
if(num==null) return null;
Arrays.sort(num);
ArrayList> res=new ArrayList>(
);
res.add(new ArrayList());// [[]]
dfs(res, num,0,new ArrayList());
return res;
}
private void dfs(ArrayList> res, int[] num, int pos,
ArrayList temp){... 阅读全帖
d****n
发帖数: 397
35
来自主题: JobHunting版 - 请教一道题 median ii
用两个heap.一个max heap,一个min heap, maxheap size = min heap size 或者
maxheap size = minheapsize + 1.
java implementation
public class Solution {
/**
* @param nums: A list of integers.
* @return: the median of numbers
*/
public int[] medianII(int[] nums) {
// write your code here
PriorityQueue pmin = new PriorityQueue ();
PriorityQueue pmax = new PriorityQueue (10, new
MaxComparator());
int i, l = nums.l... 阅读全帖
M******1
发帖数: 90
36
来自主题: JobHunting版 - 来讨论个uber的电面题
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public class UberTest {
List data = new ArrayList<>();
public void fillData(){

//Use integer to denote Time here.. you can change it to DateTime
type.
data.add(new TimedKvPair(new KvPair("name1","Bnn"), 1) );
data.add(new TimedKvPair(new KvPair("name2","Dee"), 2) );
data.add(new Time... 阅读全帖
k*z
发帖数: 4704
37
来自主题: Statistics版 - 牛牛 Xie Liang关于 Erlang C的Model应用
http://saslist.com/blog/2012/07/13/sas-functions-for-computing-
http://listserv.uga.edu/cgi-bin/wa?A2=ind1210c&L=sas-l&F=&S=&P=
SAS functions for computing parameters in Erlang-C model
Call center management is both Arts and Sciences. While driving moral and
setting up strategies is more about Arts, staffing and servicing level
configuration based on call load is in the domain of Sciences.
The science part of call center management is based on Queueing Theory,
which studies "the Phenomena of sta... 阅读全帖
s******e
发帖数: 108
38
来自主题: JobHunting版 - 问个MSFT的题
A partial solution, not finished yet for the existing element.
use two hashtable,
one hashtable used for element value
another hashtable used for element index.
O(n) complexity.
static public int[] longest2(int[] a) {
int start = 0;
int maxLen = 0;

int indexStart =0;
int indexMaxLen =0;

HashMap map = new HashMap();
HashMap indexmap = new HashMap();

for ... 阅读全帖
s******e
发帖数: 108
39
来自主题: JobHunting版 - 问个MSFT的题
A partial solution, not finished yet for the existing element.
use two hashtable,
one hashtable used for element value
another hashtable used for element index.
O(n) complexity.
static public int[] longest2(int[] a) {
int start = 0;
int maxLen = 0;

int indexStart =0;
int indexMaxLen =0;

HashMap map = new HashMap();
HashMap indexmap = new HashMap();

for ... 阅读全帖
S******1
发帖数: 216
40
来自主题: JobHunting版 - onsite一题求解
List getOrder(Map> graph) {
List res = new ArrayList();
if (graph == null || graph.isEmpty())
return res;

Set traveled = new HashSet();
Iterator it = graph.keyset().iterator();
while (it.hasNext()) {
int id = it.next();
if (!traveled.contains(id)) {
getOrderHelper(id, graph, traveled, res);
}
}

Collections.reverse(res);

return re... 阅读全帖
r********7
发帖数: 102
41
来自主题: JobHunting版 - 请教一道google面试题
抛个砖~ 自己写了一个, stack 然后 backtracking。 其实写完感觉stack多此一
举,不想改了。 请大神们无视
public class Solution {
public void printCombo(List> input){
if (input == null || input.size()==0){
return;
}
Stack> stc = new Stack>();
for (int i=0; i stc.push(input.get(i));
}
List> res = new ArrayList>();
while(!stc.isEmpty()){
List ... 阅读全帖
V***a
发帖数: 206
42
来自主题: JobHunting版 - 面试题,min steps to reduce n to 1
变形版本是hackerrank原题Down To Zero II
https://www.hackerrank.com/challenges/down-to-zero-ii
从归类看是bfs做的,下面这个bfs做法pass了。
static Map> route = new HashMap
>();
static Map cache = new HashMap();
public int downZero(int K) {
if (K == 0)
return 0;
if (cache.containsKey(K))
return cache.get(K);
Queue q = new LinkedList();
boolean[] marked = new boolean[K+1];
i... 阅读全帖
m*******1
发帖数: 77
43
来自主题: JobHunting版 - 4sum o(n^2)超时
写了一个平方复杂度的,但是一直超时。请大家帮忙看看。
public ArrayList> fourSum(int[] num, int target) {
Map cache = new HashMap();
Map> previous = new HashMap Integer>>();
ArrayList> result = new ArrayList Integer>>();
Set nima = new HashSet();
if (num.length < 4) {
return result;
}
Arrays.sort(num);
for (int i = ... 阅读全帖
f*******w
发帖数: 1243
44
背景:EE 非名校PhD 无线通信方向,预计夏天毕业,两次实习经历(12年Broadcom,
13年Amazon)
2月的时候发现时间紧迫,开始锁定SDE的目标狂投简历……真正意义上的海投,大大小
小有近百家吧,基本没有找人refer。偶尔在版上看到有人帮忙refer的时候也会问一下
,不过好像都被简历拒了- -
所有面经放上……
Bloomberg:
02/21 电面阿三,没有写具体code,都是说思路
Why bloomberg?
Mention and describe one of your projects. What is your role on this project?
Polymorphism in C++, how to implement virtual functions (vtable), different
types of polymorphisms (dynamic/static).
Two sum (with or without extra memory)
Kth node to the last (Linked List)
Implement m... 阅读全帖
p*********g
发帖数: 116
45
来自主题: JobHunting版 - 问个fb onsite题目
我贴一个吧,不过是输出数字值,不是下标的。 不知道fb要求什么。
import java.util.*;
public class Fb3Sum {

public static List> threeSum(int[] nums, int target) {
Arrays.sort(nums);
List> res = new ArrayList>();
for (int i=0; i<=nums.length-3; i++){
List> lists = twoSum(nums, i+1, target-nums[i]);
for (List list: lists) {
list.add(0, nums[i]);
}
res.addAll(lists);
... 阅读全帖
S***w
发帖数: 1014
46
来自主题: JobHunting版 - 问个fb onsite题目
我贴一个吧,不过是输出数字值,不是下标的。 不知道fb要求什么。
import java.util.*;
public class Fb3Sum {

public static List> threeSum(int[] nums, int target) {
Arrays.sort(nums);
List> res = new ArrayList>();
for (int i=0; i<=nums.length-3; i++){
List> lists = twoSum(nums, i+1, target-nums[i]);
// i 可以重用
for (List list: lists) {
list.add(0, nums[i]);
}
res... 阅读全帖
k****r
发帖数: 807
47
来自主题: JobHunting版 - how to code this question of LinkedIn
According to your approach, I tried to code one. Please kindly let me know,
if you see anything wrong:) (Here, I assume both produce and merge are
costly)
public class MergeOutput {
public static void main(String[] args) throws Exception {
List list = new ArrayList<>();
BlockingQueue bq1 = new ArrayBlockingQueue(1000);
BlockingQueue bq2 = new ArrayBlockingQueue(1000);
Producer producer = new Producer(bq1, list);
Consumer[] consumers = new Con... 阅读全帖
g***s
发帖数: 3811
48
来自主题: JobHunting版 - 生物男的Google面经节略版
It is very quick even for n = Integer.MAX_VALUE;
public static void main(String arg[]){
preprocess();
int n=Integer.MAX_VALUE;
System.out.println("squares sum of " + n + " : ");
for (int num : getSquaresSum(n)){
System.out.print(" " + num);
}
System.out.println("\ntotal callCount= " + callCount);
}
public static Collection getSquaresSum(int n){
Stack cur = new Stack();
Stack阅读全帖
s*****9
发帖数: 93
49
来自主题: JobHunting版 - leetcode的3sum的运行时间问题
用了DP,同时用了HashSet防止重复结果,运行时间无法通过Large Test. HashSet的查
找不是应该O(1)时间吗?怎样才能更快呢?请帮忙看一下:
import java.util.*;
public class Solution {
public ArrayList> threeSum(int[] num) {
HashSet> final_set = new HashSet Integer>>();
ArrayList current_list = new ArrayList();
threeSumRecur(num, 0, current_list, final_set);

ArrayList> final_lists = new ArrayList Integer>>();
... 阅读全帖
d*******y
发帖数: 27
50
基本上2,3,4-sum都是一个思路吧,用hashmao做一个的索引。我之前做
的时候都是优化一个指数级别就可以过large set了。
import java.util.*;
public class Solution {
public ArrayList> fourSum(int[] num, int target) {
// Start typing your Java solution below
// DO NOT write main() function
HashSet> result = new HashSet>
();
HashMap map = new HashMap();
ArrayList> rtn = new ArrayLis... 阅读全帖
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)