由买买提看人间百态

topics

全部话题 - 话题: getvalue
1 2 下页 末页 (共2页)
D***0
发帖数: 138
1
来自主题: 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... 阅读全帖
s********x
发帖数: 914
2
来自主题: JobHunting版 - 狗狗家onsite面经
2吧
class CharNode {
private char value;
private CharNode next;
private CharNode previous;
public CharNode getPrevious() {
return previous;
}
public void setPrevious(CharNode previous) {
this.previous = previous;
}
public char getValue() {
return value;
}
public void setValue(char value) {
this.value = value;
}
public CharNode getNext() {
return next;
}
public void setNext(CharNode next) {
this... 阅读全帖
t*******7
发帖数: 63
3
来自主题: JobHunting版 - G面经 求bless
感谢楼主分享,下礼拜电面,紧张ING。。。本人去年12月PHD毕业,专业方向DATA
MINING AND MACHINE LEARNING,搬到湾区找工作,OPT快开始了,目前还没着落,希望
能和一起在湾区找工作的同学多多交流互通信息。毕业前没时间准备现在着急了。。。
平常MATLAB写得多,JAVA最近才开始练习。。。
把电面的两个题写了一下,请拍
第一题
public boolean judgeCapital(String inputString) {

//
if ((inputString==null) || (inputString.length() == 0)) {

return false;
}



// get the first character
char firstChar = inputString.charAt(0);

//
i... 阅读全帖
l*********y
发帖数: 142
4
来自主题: JobHunting版 - 攒人品之facebook电面面经
#include
#include
#include
#include
#include
#include
#include
using namespace std;
class Counter {
public :
Counter() {
counter = 0;
}
void increment() {
counter++;
}
void decrement() {
counter --;
}
int getValue() {
return counter;
}
private:
int counter;
};
class COWString {
public:
COWString() {
pointer = NULL;
rc = new Counter();
}... 阅读全帖
a**c
发帖数: 52
5
来自主题: JobHunting版 - G家电面题
Boolean checkBasicVowel(char c) {
if (c == ‘a’ || c ==’e’ || c == ‘i’ || c ==’o’ ||
c == ‘u’ || c == ‘A’ || c ==’E’ || c == ‘I’ ||
c ==’O’ ||c == ‘U’)
return True;
}
// check whether it is vowel
Boolean checkVowel(String s, int index){
char c = s.charAt(index);
if (checkBasicVowel(c))
return True;

if (index == 0)
return False;
if (c == ‘y’ || c == ‘Y’) {
if(!checkVowel(s, index - 1))
return True;
return False;
}
return False;
}
... 阅读全帖
n******7
发帖数: 99
6
rt,还是说用ternary operator会降低可读性,所以尽量少用,换成if else语句。举
个例子,Check a binary tree is a binary search tree.
public boolean isBST(Node root){
return isBST(root,Integer.MIN_VALUE,Integer.MAX_VALUE);
}

public boolean isBST(Node root, int min, int max){
return (root==null)?true:((root.getValue()>=min)&&(root.getValue()<
max)&&isBST(root.left(),min,root.getValue())
&&isBST(root.right(),root.getValue(),max));
}
还是写成
public boolean isBST(Node root, int min, int max){
... 阅读全帖
l******n
发帖数: 577
7
来自主题: Java版 - java的volatile
Here I post the an example from thinking in java:
If you blindly apply the idea of atomicity, you see that getValue( ) in the
following program fits the description:
//: concurrency/AtomicityTest.java
import java.util.concurrent.*;
public class AtomicityTest implements Runnable {
private int i = 0;
public int getValue() { return i; }
private synchronized void evenIncrement() { i++; i++; }
public void run() {
while(true)
evenIncrement();
}
public static voi... 阅读全帖
H***e
发帖数: 476
8
来自主题: JobHunting版 - 问两道facebook面试题
第二题,
用往上面反值的方法, 左右子树传值给parent node. 总复杂度为O(n).
inside a class:
BSTNode maxsumNode = null;
int maxValue = Integer.MIN_VALUE;
public void findMaxSumSubtree(BSTNode node, MutableInt sum) {
// base cases:
if (node == null) {
sum.setValue(0);
return;
}
// normal cases:
MutableInt leftSum = new MutableInt();
MutableInt rightSum = new MutableInt();
findMaxSumSubtree(node.left, leftSum);
findMaxSumSubtree... 阅读全帖
c*****n
发帖数: 96
9
来自主题: JobHunting版 - amazon面试题目讨论贴3
Use factory pattern:
//Define a abstract class Cell which the application (Excel) will
//process.
public abstract class Cell {
....
public TValue getValue();
}
// Define concrete cell class
public class LiteralCell : Cell { // '500'
public override TValue getValue() { ... }
}
public class ExpressionCell :Cell { // 'A5 + A10'
public override TValue getValue() { ....}
}
public class FunctionCell : Cell { // 'f(A1, A2, A5)'
public override TValue getValue() { ....}
}
// define ... 阅读全帖
s********x
发帖数: 914
10
来自主题: JobHunting版 - T第二轮面经
那我写一下吧
public static Node mergeKSortedLists(Node[] l) {
// heapify: Make it a heap: Trickling Down in Place: start at node n
/2-1, the rightmost node with children
// O(n)
for (int i = (l.length / 2 - 1); i >= 0; i--)
trickleDown(l, i, l.length);

int heapSize = l.length; // size of the heap

// use an extra dummy node as the head
Node dummy = new Node();
Node pre = dummy;

while (heapSize > 0) {... 阅读全帖
e***n
发帖数: 42
11
来自主题: JobHunting版 - Facebook Phone Interview
来个java的:
public static void twoProduct(int n){

Map> m = new HashMap String>>();

for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
if (m.containsKey(i*j)){
m.get(i*j).add(Integer.toString(i) + '*' + Integer.toString(
j));
}
else{
ArrayList tmp = new ArrayList();
tmp.add(Integer.toString(i) + '*' + Integer.toString(j));
... 阅读全帖
l*********8
发帖数: 4642
12
又写了一遍,供参考
int getValue(const char * &expr) {
int val;
sscanf(expr, "%d", &val);
while (isdigit(*++expr))
;

return val;
}
int evaluate(const char *expr) {
if (!expr || !*expr) return 0;

int ans = getValue(expr);
while (*expr == '*' || *expr == '/') {
if (*expr == '*')
ans *= getValue(++expr);
else
ans /= getValue(++expr);
}

return ans + evaluate(expr);
}
c******b
发帖数: 13
13
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,可以对出现次数进行排序... 阅读全帖
m*****k
发帖数: 731
14
来自主题: Java版 - JDK HashMap 的 Entry class
有一个int 成员 hash, 貌似没有用啊, 有人知道它留着何用?
static class Entry implements Map.Entry {
final K key;
V value;
Entry next;
final int hash;
/**
* Creates new entry.
*/
Entry(int h, K k, V v, Entry n) {
value = v;
next = n;
key = k;
hash = h;
}
public final K getKey() {
return key;
}
public final V getValue() {
return val... 阅读全帖
y*********e
发帖数: 518
15
来自主题: JobHunting版 - what is java enclosure-今天被hm问倒了
感觉对方是在问 Closure。
这个是 Java 对 Lambda 表达式的实现。Java 7 已经确定在语法上支持这个。
Java 6或者以前的版本只能靠 interface + anonymous class 来实现。
若是做过 functional programming(比如haskell),应该对 Lamdba 表达
式比较熟悉。
从C++的角度来看,就是 function pointer,但是它是 Strongly Typed。
举例代码来说明。假设要对二叉树遍历,代码很好写,比如:
void inOrder(Tree tree) {
if (tree != null) {
inOrder(tree.getLeft());
System.out.println(tree.getValue());
inOrder(tree.getRight());
}
}
但是如上的函数只是把Node的值打印到终端。若是要变得generic一点,要遍历的
过程中,能引入一个函数,对每一个Node执行这个函数,该多好。这样就引入了一
个概念:能... 阅读全帖
c*****e
发帖数: 74
16
题目:一个board上,每个cell是一个字母,从一个cell出发,可以到它相邻的8个cell
。这样可以在board上walk。但是一个walk上一个cell不能出现2次。
要求:找出所有的可以由walk得到到的不同的单词。编程中可以自己假定一些已经实现
的方法。
以前面试被问到过,时间浪费在一些细节(怎么解决8个相邻cell的问题,怎么检查是
否一个cell重复出现)上了,当时也没有充分利用try,没答好,主要还是对递归、Try
的接口不熟。今天好好想了想该怎么写,下面是我的代码,花了不少时间,觉得收获不
少。好好写写这道题应该对面试很有帮助的。
有问题帮忙指出一下。
---------------------------------
class CTryNode;
class CTry
{
public:
CTryNode* Advance(CTryNode* pNode, char ch);
CTryNode* Back(CTryNode* pNode);
string GetValue(pTryNode* pNode);
bool IsCurr... 阅读全帖
D********g
发帖数: 650
17
来自主题: JobHunting版 - 问个amazon面试题
A solution with bfs, node on a complete b-tree should have continuous index
if appropriately indexed:
Boolean isCompleteBinaryTree(Node root) {
If (root == NULL) return true;
Queue> bfs = new Queue>();
Bfs.put(new Entry(root, 0));
Int currentNodeIdx = -1;
While (!bfs.empty()) {
Entry e = bfs.poll();
If (e.getValue() != ++ currentNodeIdx) {
Return false; // Node index is not continuous.
}
Node n = e.get... 阅读全帖
s*******f
发帖数: 1114
18
来自主题: JobHunting版 - amazon onsite 面经
// 给一个字符串,例如"30*(5+10)",输出计算结果。
double GetValue(double b1, double b2, char op){
switch(op){
case '+':
return b1 + b2;
case '-':
return b1 - b2;
case '*':
return b1 * b2;
case '/':
if (b2 < 0.00000001)
return 0;
return b1 / b2;
default:
return 0;
}
}
bool OpPriority(char op1, char op2){
if (op1 == '*' || op1 == '/'){
return true;
}else if ((op1 ==... 阅读全帖
o**f
发帖数: 76
19
来自主题: DotNet版 - C#中的Memory控制
我最近编了一些C#程序。有一些关于Memory的问题想请教。
The list class supports dynamic memory allocation. I
can get an element from a list with GetValue(). However,
if I modify the element I got via GetValue(), the real
element in the list is changed too. It seems that
GetValue returns the reference to that element (The C++
reference concept). Can anyone briefly describe how
memory space is managed by C#? For example, how C#
manage the memory space used by a list.
Thank you!
q*********u
发帖数: 280
20
【 以下文字转载自 JobHunting 讨论区 】
发信人: yinyueyouge (隐约有歌), 信区: JobHunting
标 题: Re: java enclosure是什么-今天被hm问倒了
发信站: BBS 未名空间站 (Fri Oct 22 09:27:57 2010, 美东)
感觉对方是在问 Closure。
这个是 Java 对 Lambda 表达式的实现。Java 7 已经确定在语法上支持这个。
Java 6或者以前的版本只能靠 interface + anonymous class 来实现。
若是做过 functional programming(比如haskell),应该对 Lamdba 表达
式比较熟悉。
从C++的角度来看,就是 function pointer,但是它是 Strongly Typed。
举例代码来说明。假设要对二叉树遍历,代码很好写,比如:
void inOrder(Tree tree) {
if (tree != null) {
inOrder(tree.getLeft());
System.out.p... 阅读全帖
b**l
发帖数: 51
21
No Need JNI. try this:
===
/*
* @(#)WinRegistry.java 1.4 03/12/19
*
* Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
met:
*
* -Redistribution of source code must retain the above copyright notice,
this
* list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright notice,
* th... 阅读全帖
h******o
发帖数: 334
22
A .txt file. Use the below java code to read the file and use a 2-D array (
one dimension for the users and other dimension for the products) to store
the order#. Also, use a dictionary to map each users to its corresponding
array row. How to replace the missing value with 0 in the 2D array?
Users, Products, order#:
name1 p1 5
name1 p2
name1 p3 2
name2 p1 3
name2 p2 1
name2 p3
name3 p1 5
name3 p2
name3 p3 2
name4 p1 3
name4... 阅读全帖
g***s
发帖数: 3811
23
来自主题: 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
24
来自主题: 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",... 阅读全帖
P**********c
发帖数: 3417
25
来自主题: JobHunting版 - on-site 面经
Singleton这个thinking in C++里有。写出来复习一下
方法一:
class Singleton{
static Singleton s;
int i;
Singleton(int x):i(x){}
Singleton& operator=(Singleton&);
Singleton(const Singleton&);
public:
static Singleton& instance() { return s;}
int getValue(){return i;}
void setValue(int x) {i=x;}
}
Singleton singleton::s(47);
方法二:
class Singleton{
int i;
Singleton(int x): i(x) {}
void operator=(Singleton&);
Singleton(const Singleton&);
public:
static Singleton& instance(){
... 阅读全帖
c*******r
发帖数: 309
26
来自主题: JobHunting版 - 关于Implement hashtable的问题
网上看的Hashtable的Implementation. 这里边定义table.put(key,value)的时候value
是必须要定义为hashEntry object么。 感觉学hashtable的时候value只要是object即
可。但是如果value不定义成hashEntry在rehash的时候无法确认table[hash]这个位置
的key是否重复。
public class HashEntry {
private int key;
private int value;
HashEntry(int key, int value) {
this.key = key;
this.value = value;
}
public int getKey() {
return key;
}
public int getValue() {
return value;
}
}
public... 阅读全帖
s********x
发帖数: 914
27
来自主题: JobHunting版 - sort list java solution
public static Node sortLinkedList(Node l) {
if (l == null) {
return null;
}

if (l.getNext() == null) {
return l;
}

Node mid = findMid(l);
Node firstHalf = l, secondHalf = mid;
firstHalf = sortLinkedList(firstHalf);
secondHalf = sortLinkedList(secondHalf);
return mergeTwoSortedLists(firstHalf, secondHalf);
}

private static Node findMid(Node l)
{
Node fast = l... 阅读全帖
m*****n
发帖数: 204
28

The following is an O(nlgn) solution for string of size n.
It maintains a heap for eligible chars, preferring longer streams.
Ineligible chars are maintained in a candidate queue, and added back
to the working queue when their position constraint is removed.
public class MinDistance {
public String rearrange(String source, int distance) {
// TODO Check params.

// WorkingQueue of eligible streams. Longest stream at head,
// but BackupStream at tail.
PriorityQueue阅读全帖
y*****e
发帖数: 712
29
public static Iterable mergeKSortedIterators(List
> Iters){

Queue minHeap = new PriorityQueue();
List result = new ArrayList();
for(Iterator iter : Iters){
if(iter.hasNext()){
minHeap.add(new newIter(iter.next(), iter));
}
}

while(!minHeap.isEmpty()){
newIter newiter = minHeap.poll();
result.add(newiter.get... 阅读全帖
h*****y
发帖数: 298
30
来自主题: JobHunting版 - 发一个Startup的面经 - Affirm
recursion比较robust但是短时间内不好写. 因为你没有可以用的语法树,所以要花力
气来tokenize. 只有用Stack才有希望在规定时间里写完,虽然这样的程序完全没有用。
public class EvalExpression {
private Stack results = new Stack();
private Stack operators = new Stack();
private Stack> vars = new Stack >>();
private static final String ADD = "add";
private static final String MULT = "mult";
private static final String LET = "let";
private static final String LPAREN... 阅读全帖

发帖数: 1
31
来自主题: JobHunting版 - 上午偷闲把TopKFrequentWords写出来了
我写的:
class Solution {
public List topKFrequentWords(String[] words, int k) {
Map map = new HashMap<>();
for (String word : words) {
map.put(word, map.getOrDefault(word, 0) + 1);
}

PriorityQueue> pq = new PriorityQueue<>(
(n1, n2) -> n2.getValue() - n1.getValue());
for (Map.Entry entry : map.entrySet()) {
pq.offer(entry);
}

List... 阅读全帖
c**t
发帖数: 26
32

Java does not have virtual functions. So der.getValue() and ba.getValue()
do the same thing. If wants to call base overridden functions, have to
use super.
c*y
发帖数: 137
33
Just to give an example; in the example, both the base and derived class has
two methods : equals and compares and they do the same thing, comparing two
objects. But equals() is OVERLOADED in the derived class and compares() is
OVERRIDDEN in the derived class. And you can see the difference between this
two:
class base{
private String value = "Base";
public String getValue(){return value;}
public void print(){System.out.println(getValue());}
public boolean equals(base b){
System.out.p
A**o
发帖数: 1550
34
来自主题: Java版 - speaking of crappy code
another one is:
if(...){...}
else{
a = getValue();
}
a = a = getValue();
and it's written by my coworker... :(
w**z
发帖数: 8232
35
来自主题: Java版 - java的volatile
you can getValue after the first i++ since getValue is not synchronized.
besides, i is not volatile, the caller thread might never see the new value.
it might read i from processor cache.

the
z****e
发帖数: 2024
36
1.D std::string lack of virtual dtr
2.E make everything an object
3.C singleton
4.
SomethingExtraordinary() : mCacheValue(mValueMaker.GetValue()){}
int GetValue() const{
return mCacheValue;
}
d****p
发帖数: 685
37
来自主题: Programming版 - 看道c++题: brianbench
OK, could you tell if the following code is OK? What's the value of a in
main()?
class Foo
{
public:
....Foo(int a) : a(a) {}
....int GetValue() { return a; }
private:
....int a;
};
int main()
{
....const Foo& foo = static_cast(Foo(1));
... int a = foo.GetValue();
....return 0;
}

is
a
do
z****e
发帖数: 2024
38
来自主题: Programming版 - 看道c++题: brianbench
you may need to have a const member function
int GetValue() const {return a;}
in my machine, the value of 'a' in main is the same as the value of 'a' in the
temporary Foo(x); (assuming the GetValue is a const mem fun.)
so, i mean, i still agree with you that tmp will be destroyed when expression is done the evaluation.
but when there is a const ref attached to the tmp, i'm not quite sure if the tmp will be deleted physically or not.
d****p
发帖数: 685
39
来自主题: Programming版 - c++ 设计问题求助
If I don't get you wrong, you are proposing code below:
class A
{
public:
...template< typename T >
...int getValue()
...{
......if (!boost::type_traits::is_same::value)
.........// static assert failure;
......return value;
private:
...int value;
...}
};
This looks nice but a.getValue() can be called anywhere by anybody.
If LZ really wants B is the only class that can access A's certain member
variables (ie value), some injection form could be tried, ie
class A
{
public:
...void inject... 阅读全帖
gw
发帖数: 2175
40
package unmar;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
/*
@XmlRootElement(name = "root") public class Expense {
private String title;
private String category;
private String period;
private String value;
public Expense() {} //Default constructor is needed for XML-handling
public Expense(String title, String value, String period, String category) ... 阅读全帖
gw
发帖数: 2175
41
package unmar;
import java.io.File;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
public class Demo {
public static void main(String[] args) throws Exception {
JAXBContext jc = JAXBContext.newInstance(MyWrapperForList.class,
Expense.class);
//UNMARSHALLING
Unmarshaller unm... 阅读全帖
c*********n
发帖数: 1282
42
来自主题: Military版 - LC 387 怎么优化
希望大家都能拿到大包裹,我帖一个答案吧。其实就一层床糊纸。
import java.io.IOException;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import java.util.Set;
public class FirstUniqueCharacter {

public int firstUniqChar(String s)
{
Set set = new HashSet();
LinkedHashMap result = new LinkedHashMap Integer>();
for (int i=0; i char c = s.charAt(i);
if (set.contains(c)) {
resu... 阅读全帖
a******t
发帖数: 34
43
来自主题: JobHunting版 - G questions
1. Write code to find the next prime number after a given number.
2. How would you write a benchmark to calculate the time of each memory
access?
3. Searching of images has a feature where you are shown related searches (
eg, people who searched X also searched Y). How would you design this
feature?
4. Imagine you have data being pulled very frequently from a large database.
How would you design a MRU (most recently used) cache? Implement getValue(
int id) for the MRU cache.
a******t
发帖数: 34
44
来自主题: JobHunting版 - Goog questions
1. Write code to find the next prime number after a given number.
2. How would you write a benchmark to calculate the time of each memory
access?
3. Searching of images has a feature where you are shown related searches (
eg, people who searched X also searched Y). How would you design this
feature?
4. Imagine you have data being pulled very frequently from a large database.
How would you design a MRU (most recently used) cache? Implement getValue(
int id) for the MRU cache.
y*********e
发帖数: 518
45
来自主题: JobHunting版 - BST to double linked list的code
BST to Doubly Linked List:
public LinkedList convert(BTree tree) {
LinkedList list = new LinkedList();
convert(tree, list);
return list;
}
private void convert(BTree tree, LinkedList list) {
if (tree != null) {
convert(tree.getLeftChild(), list);
LinkedListNode node = new LinkedListNode(tree.getValue());
list.add(node); // append to tail
convert(tree.getRightChild(), list);
}
}
看起来很眼熟把?就是in-order的tree traverse而已。
至于LinkedList的实现。。
public cl
p*****2
发帖数: 21240
46
来自主题: JobHunting版 - G家一面。
我写了一个练练手。
import java.util.*;
public class test3
{
public static void main(String[] args)
{
Interval in = new Interval();
int[][] sam = new int[][]
{
{ 5, 10 },
{ 15, 17 },
{ 18, 25 },
{ 16, 35 } };
for (int i = 0; i < sam.length; i++)
{
in.Merge(sam[i][0], sam[i][1]);
in.Print();
}
}
}
class Interval
{
TreeMap tm = new TreeMap();
void Me... 阅读全帖
e***n
发帖数: 42
47
来自主题: JobHunting版 - 问一个anagram的题
一个文件,每行一个单词,要求编程输出所有的 anagram,比如:
input:
abc
bac
asbd
sadb
output:
[abc, bac]
[asbd, sadb]
写了一个Java的,请帮忙高手帮忙看看有什么可以改进的:
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
import java.util.Arrays;
public class FileReadTest {
public static void main(String[] aArgs) throws IOException {
String fileName = aArgs[0];
String word;
String anagram;
Map wTable = new HashMap();

// Read words from file
List text;
Scanner scanner = new Scanner(n... 阅读全帖
p*****2
发帖数: 21240
48
来自主题: JobHunting版 - leetcode 这题insert interval怎么做?
刚才又重写了一遍
class Solution1
{
TreeMap tm = new TreeMap();
void insert(Interval interval)
{
Integer prev = tm.floorKey(interval.start);
Integer next = tm.ceilingKey(interval.start);
if (prev != null && tm.get(prev) >= interval.start || next != null
&& interval.end >= next)
{
int start = -1;
if (prev != null && tm.get(prev) >= interval.start)
{
tm.put(pre... 阅读全帖
p*****2
发帖数: 21240
49
来自主题: JobHunting版 - leetcode 这题insert interval怎么做?
刚才又重写了一遍
class Solution1
{
TreeMap tm = new TreeMap();
void insert(Interval interval)
{
Integer prev = tm.floorKey(interval.start);
Integer next = tm.ceilingKey(interval.start);
if (prev != null && tm.get(prev) >= interval.start || next != null
&& interval.end >= next)
{
int start = -1;
if (prev != null && tm.get(prev) >= interval.start)
{
tm.put(pre... 阅读全帖
b**a
发帖数: 62
50
来自主题: JobHunting版 - G電面 大家參詳一下怎麼個狀況
這樣啊 當時也沒想到這麼多 在getRandom的時候我是先getValues然後得到一個array
然後在生成一個隨機數 不知道這樣行不行
1 2 下页 末页 (共2页)