由买买提看人间百态

topics

全部话题 - 话题: boolean
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
b*******h
发帖数: 53
1
求各位大牛指导, 这个题目我扫描整个string。用boolean表示当前的状态, 每个
char可以看之前的状态进行判断,逻辑上是不是比较清楚一点。贴上代码:
public boolean isNumber(String s) {
s = s.trim();
if(s.length() == 0) return false;
if(s.charAt(0) == '+' || s.charAt(0)=='-') return isNum(s.substring(
1,s.length()));
else return isNum(s);
}

public boolean isNum(String s){
boolean hasInteger = false, hasDot = false, hasDecimal = false,
hasPow = false, hasSign = false, hasExponent = false;
for (ch... 阅读全帖
b*******h
发帖数: 53
2
求各位大牛指导, 这个题目我扫描整个string。用boolean表示当前的状态, 每个
char可以看之前的状态进行判断,逻辑上是不是比较清楚一点。贴上代码:
public boolean isNumber(String s) {
s = s.trim();
if(s.length() == 0) return false;
if(s.charAt(0) == '+' || s.charAt(0)=='-') return isNum(s.substring(
1,s.length()));
else return isNum(s);
}

public boolean isNum(String s){
boolean hasInteger = false, hasDot = false, hasDecimal = false,
hasPow = false, hasSign = false, hasExponent = false;
for (ch... 阅读全帖
c******s
发帖数: 48
3
菜鸟来求习题。
老师上课讲的内容都听懂了,可是一做题,就不会了。

(1) scheme programming 。顺便请问下scheme编程有没有套路?
(2)Boolean expression 化简,或者证明两个Boolean expression 相等
(3)按要求设计circuit, 用NOR, NAND, AND, OR, NOT, selector
最好是有答案的。
我在google上没有找到,有的要教师有密码的才能看答案。
c******k
发帖数: 1140
4
简单的表示On/OFF 或者 True/False, 我把Labview中的Button&Switch 和Classic
Boolean 就混用了,比如 On/OFF 就用了Classic Boolean,而True/False时候就用了
Button&Switch,今天才发现程序有时候会有问题,有时候也没事,说不清楚,请牛人
指导一下?是不是不能混用? 谢
a***e
发帖数: 30
5
static void foo( boolean * validPtr )
谢谢。
d*****r
发帖数: 39446
6
来自主题: _ChemRelatedJobHunting版 - [通知] 恭喜 Boolean 成为本俱乐部正式成员
【此篇文章是由自动发信系统所张贴】
Boolean 已经成为本俱乐部的正式成员, 特此通知.
d*****r
发帖数: 39446
7
【此篇文章是由自动发信系统所张贴】
Boolean 已经成为本俱乐部的正式成员, 特此通知.
d*****r
发帖数: 39446
8
来自主题: _chemistry_discussion_club版 - [通知] 恭喜 Boolean 成为本俱乐部正式成员
【此篇文章是由自动发信系统所张贴】
Boolean 申请加入本俱乐部的请求已经通过审批, 成为本俱乐部的正式成员, 特此通知.
f**d
发帖数: 768
9
来自主题: Neuroscience版 - eBook: From computer to brain
这是一本计算神经科学的优秀著作,全文拷贝这里(图和公式缺),有兴趣的同学可以
阅读
如需要,我可以分享PDF文件(--仅供个人学习,无商业用途)
From Computer to Brain
William W. Lytton
From Computer to Brain
Foundations of Computational Neuroscience
Springer
William W. Lytton, M.D.
Associate Professor, State University of New York, Downstato, Brooklyn, NY
Visiting Associate Professor, University of Wisconsin, Madison
Visiting Associate Professor, Polytechnic University, Brooklyn, NY
Staff Neurologist., Kings County Hospital, Brooklyn, NY
In From Computer to Brain: ... 阅读全帖
d**********o
发帖数: 1321
10
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
hw3 & hw3b 最终结果
贴一个自己 hw3b 的 match 结果让小伙伴们感受一下我们作业需要的结果是什么样子
的。
如果是同专业的小伙伴,最后拷贝到编辑器中仔细看一下,这个网页因为宽度有限,让
并排两列的比较呈现出来的很变形。
=================================================
Output of Building User Code
Explode the tar
c-.l
c-.y
makefile
scanType.h
symtab.h
symtab.c
20131116163236-(me~~)-CS445-F13-A3B.tar: POSIX tar archive (GNU)
Tests: directory
c-.l: lex description text
c-.y: lex description text
... 阅读全帖
d**********o
发帖数: 1321
11
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
hw3b deadline前版本
这里我也先公开承认一下自己早前犯过的错误,在这个楼的第 14 页、第 265 楼,我
有贴出自己的hw3b,但现在我必须向亲爱的读者一一您公开道歉。因为当时因为着急,
我没能找到hw3b deadline前的版本,就把这次作业后来的最终版本(也就是那个楼贴
出来的,只剩下ReturnK、CompoundK两条小尾巴的版本,那个版本被我改动了时间戳我
现在已经把它改回来了。相比于急于求成绩,我更希望自己作一个诚实的人,希望大家
能原谅)给贴出来了。因为我们作业deadline之后也还都是可以接着交的,所以任何作
业,老师都是可以根据后来的版本,追终到这个学生的最后进展的,这个最新进展老师
到底给不给分、就要看老师如何下决定了。
deadline前的版本,被我附在下面了。
当然,把自己的这个版本更新后,我愿为这个楼(这一次出来写的所有)属于自己的每
个贴子负责,所有写出来的,都是真实发生过的事。
=================================================
Output of Building User Code
Ex... 阅读全帖
d**********o
发帖数: 1321
12
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
hw3 & hw3b 最终结果
贴一个自己 hw3b 的 match 结果让小伙伴们感受一下我们作业需要的结果是什么样子
的。
如果是同专业的小伙伴,最后拷贝到编辑器中仔细看一下,这个网页因为宽度有限,让
并排两列的比较呈现出来的很变形。
=================================================
Output of Building User Code
Explode the tar
c-.l
c-.y
makefile
scanType.h
symtab.h
symtab.c
20131123233236-(me~~)-CS445-F13-A3B.tar: POSIX tar archive (GNU)
Tests: directory
c-.l: lex description text
c-.y: lex description text
... 阅读全帖
d**********o
发帖数: 1321
13
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
hw3b deadline前版本
这里我也先公开承认一下自己早前犯过的错误,在这个楼的第 14 页、第 265 楼,我
有贴出自己的hw3b,但现在我必须向亲爱的读者一一您公开道歉。因为当时因为着急,
我没能找到hw3b deadline前的版本,就把这次作业后来的最终版本(也就是那个楼贴
出来的,只剩下ReturnK、CompoundK两条小尾巴的版本,那个版本被我改动了时间戳我
现在已经把它改回来了。相比于急于求成绩,我更希望自己作一个诚实的人,希望大家
能原谅)给贴出来了。因为我们作业deadline之后也还都是可以接着交的,所以任何作
业,老师都是可以根据后来的版本,追终到这个学生的最后进展的,这个最新进展老师
到底给不给分、就要看老师如何下决定了。
deadline前的版本,被我附在下面了。
当然,把自己的这个版本更新后,我愿为这个楼(这一次出来写的所有)属于自己的每
个贴子负责,所有写出来的,都是真实发生过的事。
=================================================
Output of Building User Code
Ex... 阅读全帖
d**********o
发帖数: 1321
14
来自主题: 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
15
来自主题: 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... 阅读全帖
w*s
发帖数: 7227
16
my DB is in the local pc, some times my program gave such errors, while most
of the time is ok.
any suggestions ?
Unhandled Exception: System.Data.EntityException: The underlying provider
failed
on Open. ---> System.Data.SqlClient.SqlException: A network-related or
instance
-specific error occurred while establishing a connection to SQL Server. The
serv
er was not found or was not accessible. Verify that the instance name is
correct
and that SQL Server is configured to allow remote connections. ... 阅读全帖
f***8
发帖数: 641
17
不行啊。。。我右键单击得到那个视频的属性是framerate=25.
我试了把你给我的那个改成framerate=20/1就报错,但是改成framerate=25/1就OK。
你给我的那个是这样的:
gst-launch filesrc "location=1.MPG" ! decodebin ! video/x-raw-yuv, width=640
,height=480,framerate=25/1 ! ffmpegcolorspace ! jpegenc ! multipartmux !
tcpserversink host=192.168.2.1 port=5006
这个运行OK。但是如果直接写成framerate=25/1就报错。
于是我加了"!videoscale!"在decodebin和cap之间,又把framerate改成15:
gst-launch filesrc "location=1.MPG" ! decodebin ! videoscale ! video/x-raw-
yuv, width=640,height=480,framerate=15/1 ! ffm... 阅读全帖
d**********o
发帖数: 1321
18
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
最终版本的compiler测试结果
=================================================
Output of Building User Code
Explode the tar
c-.l
c-.y
scanType.h
makefile
symtab.h
symtab.cpp
emitCode.h
emitCode.cpp
20131214164956-huang-CS445-F13-A5.tar: POSIX tar archive (GNU)
Tests: directory
c-.l: lex description text
c-.y: lex description text
emitCode.cpp: ASCII C++ program text
emitCode.h: ... 阅读全帖
d**********o
发帖数: 1321
19
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
最终版本的compiler测试结果
=================================================
Output of Building User Code
Explode the tar
c-.l
c-.y
scanType.h
makefile
symtab.h
symtab.cpp
emitCode.h
emitCode.cpp
20131214164956-huang-CS445-F13-A5.tar: POSIX tar archive (GNU)
Tests: directory
c-.l: lex description text
c-.y: lex description text
emitCode.cpp: ASCII C++ program text
emitCode.h: ... 阅读全帖
w***n
发帖数: 4358
20
☆─────────────────────────────────────☆
Boolean (Soso) 于 (Wed Oct 26 20:31:01 2011, 美东) 提到:
感谢somekiss的十个包子,用那十个包子请人查了下VIN
来到美国大农村,没车还真不行。没钱搞新车,就淘了辆二手的
菜车一辆, 2002 Ford Crown Victoria,1st owner, 警车,8万迈, 4k刀
积累了些买二手车的经验,以后有谁需要,有问必答。
☆─────────────────────────────────────☆
Viaaa (大V) 于 (Wed Oct 26 21:40:07 2011, 美东) 提到:
退役警车?这么牛
☆─────────────────────────────────────☆
rcf (hello world) 于 (Wed Oct 26 21:43:39 2011, 美东) 提到:
zan sk

☆─────────────────────────────────────☆
whbin (御风~探... 阅读全帖
w**2
发帖数: 724
21
请问@6是什么意思?
我用ssms打开database看了,一切正常。
求救,大谢!
Unhandled Exception: System.Data.Entity.Infrastructure.DbUpdateException: An
error occurred while up
dating the entries. See the inner exception for details. ---> System.Data.
UpdateException: An error
occurred while updating the entries. See the inner exception for details. --
-> System.Data.SqlClient
.SqlException: The incoming tabular data stream (TDS) remote procedure call
(RPC) protocol stream is
incorrect. Parameter 9 ("@6"): The supplied value is... 阅读全帖
w***n
发帖数: 4358
22
☆─────────────────────────────────────☆
Boolean (Soso) 于 (Thu Sep 23 10:08:31 2010, 美东) 提到:
为什么, 为什么, 为什么 啊?(“咆哮帝” 马景涛 状)
☆─────────────────────────────────────☆
macbookair (苹果妞) 于 (Thu Sep 23 10:10:18 2010, 美东) 提到:
说啥捏?
☆─────────────────────────────────────☆
Viaaa (大V) 于 (Thu Sep 23 10:49:37 2010, 美东) 提到:
BSO他长得年轻并且心态成熟

☆─────────────────────────────────────☆
vanBasten9 (仙4……仙1之后好久没为游戏感动过了……) 于 (Thu Sep 23 11:08:57 2010, 美东) 提到:
恩,俺也是这么想滴,俺是多么想有20岁的相貌和40岁的心态啊~~~~~~
☆──────... 阅读全帖
K****n
发帖数: 5970
23
来自主题: Biology版 - 浅谈生物信息的职业发展规划
My colleague pointed me to msdn. You can search for SSAS tutorial
Several links that might give a quick look:
http://technet.microsoft.com/en-us/library/bb510516.aspx
http://technet.microsoft.com/en-us/library/ms131986.aspx
I promise you will see lots of familiar algorithms here :)
http://technet.microsoft.com/en-us/library/ms175443.aspx
Algorithms Category
Microsoft_Association_Rules\ Enabled
A Boolean property that indicates whether the Microsoft_Association_Rules
algorithm is enabled.
Microso... 阅读全帖
n**e
发帖数: 116
24
public class Solution {
private final Map> adj = new HashMap<>();
public boolean canFinish(int numCourses, int[][] prerequisites) {
for (int i = 0; i < prerequisites.length; ++i) {
int u = prerequisites[i][0], v = prerequisites[i][1];
addEdge(u, v);
}
boolean[] visited = new boolean[numCourses];
boolean[] recursionStack = new boolean[numCourses];
for (Integer v : adj.keySet()) {
if (hasCycl... 阅读全帖
b**l
发帖数: 51
25
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... 阅读全帖
r******r
发帖数: 700
26
再问个与 Vector deprecated 相关的问题。如果不用 Vector, 就用 Collections.
synchronizedCollection(...). 因为它返回一个 “a synchronized (thread-safe)
collection backed by the specified collection. ”。
public static Collection synchronizedCollection(Collection c) {
return new SynchronizedCollection(c);
}
但是,在使用的时候,为何还要对返回的 collection c 再次 synchronized(c),如下
。不是已经安全了吗?
Collection c = Collections.synchronizedCollection(myCollection);
...
synchronized(c) {
Iterator i = c.iterator(); // Must ... 阅读全帖
m*******r
发帖数: 339
27
来自主题: JobHunting版 - 贡献今天facebook电面 一道题
我练练手,试着写了下:
public class StringPath {
public static boolean stringMatch(char[][] m, String s) {
StringBuffer sb = new StringBuffer();
boolean visited[][] = new boolean[m.length][m[0].length];
boolean found = false;
for (int i=0;i for (int j=0;j if (searchDFS(m, i, j, s, 0, visited, sb)) found = true;
}
}
return found;
}
public static boolean searchDFS(char[][] m, int x, int y, String s, int pos, boolean[][] v, S... 阅读全帖
c****g
发帖数: 85
28
code is here. Please comment on this.
平时不用Java的,发现做题用Java比C++方便(没指针,有更多的函数,呵呵)
另外,函数返回一个boolean(有可能数组根本没有k这么多elements)和一个number。
查了网,说可以用一个临时类,来返回其对象。我嫌麻烦,用了一个输入变量来返回
number值。但是直接不能返回,所以用了int[]。觉得有点awkward。不知你们怎么处理?
package leetcode;
import java.util.*;
public class kthSmallestElementTwoSortedArrays_Ver2 {

public static void main(String[] str)
{
// build two sorted arrays:
int[] A = {1,3,4,4, 7,9,10, 13, 15, 19, 20, 33};
int[] B = {2,5,5,6,12 };

// ... 阅读全帖
p*****2
发帖数: 21240
29
来自主题: JobHunting版 - 准备转回Java了

object test6 extends App {
val sc=new Scanner(System.in)
val n=sc.nextInt
val m=sc.nextInt
val mat=new Array[String](n)
val start=System.currentTimeMillis()
for(i<-0 until n) mat(i)=sc.next()

def check(i:Int, j:Int, k:Int, l:Int):Boolean={
val minX=math.min(i,k)
val maxX=math.max(i,k)
val minY=math.min(j,l)
val maxY=math.max(j,l)

var minR=true
var maxR=true
var minC=true
var maxC=true
... 阅读全帖
c***d
发帖数: 26
30
来自主题: JobHunting版 - 发现valid number真是必杀题
这题似乎不值得用状态机,按顺序检查过去就好。
不过写这么多if/while的确很吐血。。。
还有要事先问清很多情况是否符合,比如e前后可否出现空格
public class Solution {
public boolean isNumber(String s) {
// Start typing your Java solution below
// DO NOT write main() function
if(s==null) return false;
int len = s.length();
int i=0;
boolean isNumber = false;
while(i if(i while(i isN... 阅读全帖
h*********d
发帖数: 336
31
来自主题: JobHunting版 - 大牛帮我看一段code
phone interview, 实现一个in-memory filesystem. 刚开始面试,还没有摸到门路,
请大牛指点
Write an in memory filesystem! This is a simplified file system that only
supports directories. Your code needs to read from a file and parse the
commands listed below.
cd - Changes the current working directory. The working
directory begins at '/'. The special characters '.' should not modify the
current working directory and '..' should move the current working directory
to the parent.
mkdir - Creates a new dire... 阅读全帖
n********n
发帖数: 529
32
这是我当时写的,1个半小时左右吧。
/////////////////////////////////////////////////////
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.HashSet;
public class TestForSalesforce {
// Variable to track the dependencies
HashMap> deps = new HashMap String>>();
// Variable to track the installed commands
HashMap ins = new HashMap();

public boolean... 阅读全帖
j**7
发帖数: 143
33
来自主题: JobHunting版 - FB Onsite新题,有人能看看吗?
boolean alibaba(int numCaves, int[] strategy) {
boolean[] DP = new boolean[numCaves];
boolean canWin = true;
for (int k = strategy.length - 1; k >= 0; k--) {
boolean[] temp = new boolean[numCaves];
for (int i = 0; i < numCaves; i++) {
temp[i] = (strategy[k] == i) ? true : false;
if (k + 1 < strategy.length) {
boolean result= true;
if (i - 1 >= 0) {
resul... 阅读全帖
P********l
发帖数: 452
34
How about this version using Dynamic Programming?
The basic idea is fill in a table for a matching path. If the last pair
matches, the whole string will match.
mtch is the array, which is of (string length + 1)*(pattern length + 1).
mtch[0][*] and mtch[*][0] is padded with false.
Then the function is something like:
mtch[i][j] =
1. if pattern char='.', mtch[i][j]=mtch[i-1][j-1]
2. if pattern char='*', mtch[i][j]=mtch[i-1][j-1] || mtch[i][j]=mtch[i-1][
j]
3. if pattern char=string char, mtc... 阅读全帖
c***d
发帖数: 26
35
来自主题: JobHunting版 - [难题求助] leetcode wordsearch
这题野蛮暴力就能通过大case呀。
public class Solution {
public boolean exist(char[][] board, String word) {
// Start typing your Java solution below
// DO NOT write main() function
if (board==null) return false;
boolean visited[][] = new boolean[board.length][board[0].length];
for(int i = 0; i < board.length; i++) {
for(int j = 0; j < board[0].length; j++) {
if (helper(board, visited, word, i, j, 0)) return true;
}
}
... 阅读全帖
F****n
发帖数: 3271
36
来自主题: JobHunting版 - Java编程讨论:LinkedIn的H2O
public class H2O {
public static class ThreadHolder {
Thread thread;
ThreadHolder(Thread thread) {
this.thread = thread;
}
}
protected LinkedList hlist = new LinkedList();
protected LinkedList olist = new LinkedList();
public boolean h() {
ThreadHolder current = new ThreadHolder(Thread.currentThread());
synchronized (current) {
ThreadHolder[] threadsToWakeUp = null;
// updating the queues requires a global lock;
sy... 阅读全帖
z****e
发帖数: 54598
37
来自主题: JobHunting版 - Java编程讨论:LinkedIn的H2O
因为wait的monitor在l上,而不是在ti上
这个问题可以单独剥离出来看,如果写成一堆的话
那就非常不容易阅读了,这是代码
List l = new ArrayList();

public void h() throws InterruptedException {
ThreadInfo ti =null;

synchronized(l){
if (l.size() >= 2) {
ThreadInfo hThread = l.get(0);
ThreadInfo oThread = l.get(l.size() - 1);
if (hThread.isH() && oThread.isO()) {
synchronized(hThread){
hThrea... 阅读全帖
F****n
发帖数: 3271
38
来自主题: JobHunting版 - Java编程讨论:LinkedIn的H2O
public class H2O {
public static class ThreadHolder {
Thread thread;
ThreadHolder(Thread thread) {
this.thread = thread;
}
}
protected LinkedList hlist = new LinkedList();
protected LinkedList olist = new LinkedList();
public boolean h() {
ThreadHolder current = new ThreadHolder(Thread.currentThread());
synchronized (current) {
ThreadHolder[] threadsToWakeUp = null;
// updating the queues requires a global lock;
sy... 阅读全帖
z****e
发帖数: 54598
39
来自主题: JobHunting版 - Java编程讨论:LinkedIn的H2O
因为wait的monitor在l上,而不是在ti上
这个问题可以单独剥离出来看,如果写成一堆的话
那就非常不容易阅读了,这是代码
List l = new ArrayList();

public void h() throws InterruptedException {
ThreadInfo ti =null;

synchronized(l){
if (l.size() >= 2) {
ThreadInfo hThread = l.get(0);
ThreadInfo oThread = l.get(l.size() - 1);
if (hThread.isH() && oThread.isO()) {
synchronized(hThread){
hThrea... 阅读全帖
A*******e
发帖数: 2419
40
来自主题: JobHunting版 - 怎么准备一些hardcore C++的interview
初级对应高级,底层对应高层。初级和底层不是对立关系啊。
这本书里的例子,很多会影响代码可读性。比如下面这段,7.9a比7.9.b好理解多了。而
且编译器自己也会优化。扣细节显然过头了。
Boolean variables are overdetermined in the sense that all operators that
have Boolean variables as input check if the inputs have any other value
than 0 or 1, but operators that have Booleans as output can produce no other
value than 0 or 1. This makes operations with Boolean variables as input
less efficient than necessary. Take the example:
// Example 7.9a
bool a, b, c, d;
c = a && b;
d = a || b;
This... 阅读全帖
l*****o
发帖数: 214
41
public class NumberPickGame {

public NumberPickGame() {}

public static boolean canIForceWin(int maxNumber, int total) {
if ((maxNumber + 1) * maxNumber /2 < total) {
return false;
}
Set numbersAvailable = new HashSet();
for (int i = 1; i <= maxNumber; i++) {
numbersAvailable.add(i);
}
int[] picks = new int[maxNumber];
boolean canWin = canFirstPlayerWin(numbersAvailable, total, 0, pic... 阅读全帖
j**7
发帖数: 143
42
来自主题: JobHunting版 - FB Onsite新题,有人能看看吗?
boolean alibaba(int numCaves, int[] strategy) {
boolean[] DP = new boolean[numCaves];
boolean canWin = true;
for (int k = strategy.length - 1; k >= 0; k--) {
boolean[] temp = new boolean[numCaves];
for (int i = 0; i < numCaves; i++) {
temp[i] = (strategy[k] == i) ? true : false;
if (k + 1 < strategy.length) {
if (i - 1 >= 0) {
temp[i] = temp[i] || DP[i - 1];
... 阅读全帖
p****6
发帖数: 724
43
来自主题: JobHunting版 - FLGU面经offer及杂谈

public static boolean canIWin(int rangeMax, int target) {
if(rangeMax * (rangeMax + 1) /2 < target)
return false;
boolean[] visited = new boolean[rangeMax+1];
return recursive(0, rangeMax, target, visited);
}

private static boolean recursive(int cur, int rangeMax, int target,
boolean[] visited){
if(cur >= target) return false;
for(int i = 1; i <= rangeMax; i++){
if(!visited[i]){
visited[i] = true;
... 阅读全帖
m******3
发帖数: 346
44
来自主题: JobHunting版 - FLGU面经offer及杂谈
非常感谢,结合楼主发的tutorial,基本懂了,加点我理解的吧
public static boolean canIWin(int rangeMax, int target) {
if(rangeMax * (rangeMax + 1) /2 < target)
return false;
boolean[] visited = new boolean[rangeMax+1];
return recursive(0, rangeMax, target, visited);
}

private static boolean recursive(int cur, int rangeMax, int target,
boolean[] visited){
if(cur >= target) return false;
// 说明对手拿完以后,和>=target,所以对手获胜,我输
//尝试我所有可能的拿法,如果我拿了以后,对其中一个拿法,有heWin=false,则我可
以保证获... 阅读全帖
p****6
发帖数: 724
45
来自主题: JobHunting版 - FLGU面经offer及杂谈

public static boolean canIWin(int rangeMax, int target) {
if(rangeMax * (rangeMax + 1) /2 < target)
return false;
boolean[] visited = new boolean[rangeMax+1];
return recursive(0, rangeMax, target, visited);
}

private static boolean recursive(int cur, int rangeMax, int target,
boolean[] visited){
if(cur >= target) return false;
for(int i = 1; i <= rangeMax; i++){
if(!visited[i]){
visited[i] = true;
... 阅读全帖
m******3
发帖数: 346
46
来自主题: JobHunting版 - FLGU面经offer及杂谈
非常感谢,结合楼主发的tutorial,基本懂了,加点我理解的吧
public static boolean canIWin(int rangeMax, int target) {
if(rangeMax * (rangeMax + 1) /2 < target)
return false;
boolean[] visited = new boolean[rangeMax+1];
return recursive(0, rangeMax, target, visited);
}

private static boolean recursive(int cur, int rangeMax, int target,
boolean[] visited){
if(cur >= target) return false;
// 说明对手拿完以后,和>=target,所以对手获胜,我输
//尝试我所有可能的拿法,如果我拿了以后,对其中一个拿法,有heWin=false,则我可
以保证获... 阅读全帖
a*****p
发帖数: 1285
47
来自主题: Java版 - java graphics2d 画图请教
public class MouseComponent extends JComponent {



public MouseComponent() {

shapes = new ArrayList();
lines = new ArrayList();
bounds = new ArrayList();
current = null;
startpoint = null;
endpoint = null;

isSelected = false;
eraserSelected = false;
cursorPointer = false;
isLine = false;
clear = false;
filled = false;

shapeIndex =... 阅读全帖
z****n
发帖数: 1379
48
来自主题: JobHunting版 - 攒人品,google电话面经
boolean HasPath(Point source, Point dest)
{
boolean up = false;
boolean down = false;
boolean left = false;
boolean right = false;
source.visited=true;
if(source.equals(dest))return true;
if(IsBlock(source))return false;
if(Up(source)!=null && !Up(source).visited)
up = HasPath(Up(source), dest);
if(Down(source)!=null && !Down(source).visited)
down = HasPath(Down(source), dest);
if(Left(source)!=null && !Left(source).visited)
S*******0
发帖数: 198
49
来自主题: JobHunting版 - chess game的OOD
public abstract class Piece {
private String pieceColor;
public Piece() {
}
public String getPieceColor() {
return pieceColor;
}
// boolean isOppositeColor()
abstract public String getName();
abstract public boolean isRoadOk(Board board, String from, String to);
}
King, Queen, Bishop, Knight, Rook, Pawn 都继承一下Piece
public class Board {
private Square[][] squares = new Square[8][8];
public Board() {
//set the 32 pieces
}
public Square[][]... 阅读全帖
k*********6
发帖数: 738
50
来自主题: JobHunting版 - [难题求助] leetcode wordsearch
public class Solution {
public boolean exist(char[][] board, String word) {
// Start typing your Java solution below
// DO NOT write main() function
//DFS
if (word == null || word.length() == 0) return true;
if (board == null || board.length == 0|| board[0].length == 0)
return false;

boolean[][] visited = new boolean[board.length][board[0].length];

for (int i = 0; i < board.length; i++)
{
for(int j = ... 阅读全帖
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)