IT 討論區(48)最強工種,FG25K,你!敢唔敢成功?

1001 回覆
6 Like 0 Dislike
2018-11-26 20:14:14
JP 3xk + 日本妹
vs HK 3xk + 無日本妹
盲都識揀
2018-11-26 20:22:26
其實日本p仔人工有幾多
2018-11-26 20:38:55
FG應該200-300k,計返同香港一樣,但税多d
2018-11-26 21:05:38
上次見到有囡上黎in
老細話太鈍唔請
2018-11-26 21:19:35
今朝嗰條題目:
return int array......
2018-11-26 21:49:06
所以我只可以喺香港呃飯食
2018-11-26 22:02:04
BBA degree 咩都唔識
係咪就咁報個bootcamp出黎就有25k?
想轉行
2018-11-26 22:12:37
2018-11-26 22:57:17
唔係,淨係hr已經過唔到,25k要cs-related再加intern,埋位可以即食
2018-11-26 22:59:44
唔洗報bootcamp
好易25k, HKTV果D可能未必得
因為果D真做, 實戰
我教你GOOGLE 大法, 每月逗25k
2018-11-26 23:10:45
咁做唔知得唔得
將A向左sift一格, 出 B =-floor(A)
e.g. let A = 101101
B = A = 101111 => 01101

之後將floor轉ceil同乘-1, 出C = ceil(A)
C = array of zero
B[0] -=A[0]
if B[0] = -1, C[0] = 1
for i in B:
if B[i]=1: C[i]++, C[i+1]++
e.g. C = 000000 => 100000 => 111000 => 112100 => 112111

p.s. C[i] = 0, 1 or 2, |C[i]-C[i+1]|<=1

進位
for i in C:
if C[i] =2:
C[i] = 0, C[i+1] --
e.g. C = 112111 => 110011
2018-11-26 23:25:28

2018-11-26 23:28:34
[quote][quote][quote][quote]```
public class Solution {
	
	public int[] powerSet;
	
	public int[] solution(int[] A) {
		int length = A.length;
		if (length == 0)
			return A;
		powerSet = new int[length];
		int sum = 0;
		for (int i = 0; i < A.length; i++) {
			if (A[i] == 1) {
				int power = pow(-2, i);
				powerSet[i] = power;
				sum += power;
			}
		}
		
		int ceil;
		if (sum % 2 == 1 && sum > 0) {
			ceil = sum / 2 + 1;
		} else {
			ceil = sum / 2;
		}
		
		int index = getLeadingIndex(ceil);
		int[] array = new int[index+1];
		array[index] = 1;
		ceil -= powerSet[index];
		while (ceil != 0) {
			index = getLeadingIndex(ceil);
			array[index] = 1;
			ceil -= powerSet[index];
		}

		return array;
	}
	
	public int pow(int base, int power) {
		int number = 1;
		while (power-- > 0) {
			number *= base;
		}
		return number;
	}
	
	public int getLeadingIndex (int number) {
		int index = 0;
		int sum = 0;
		if (number > 0) {
			index = -2;
			while (sum < number) {
				index += 2;
				sum += powerSet[index];
			}
		} else if (number < 0) {
			index = -1;
			while (sum > number) {
				index += 2;
				sum += powerSet[index];
			}
		}
		return index;
	}
}

幅圖睇唔到assumption,如果length of array太大,可能要再tune[/quote]Brute force係2^n,你呢個solution係n^2,length of array如果4位數可能要再optimize[/quote]都係無野,long都係得2^63,n^2夠做[/quote]

咁做唔知得唔得
將A向左sift一格, 出 B =-floor(A)
e.g.  let A = 101101
B = A = 101111 => 01101

之後將floor轉ceil同乘-1, 出C = ceil(A)
C = array of zero
B[0] -=A[0]
if B[0] = -1:
   C[0] = 1
for i in range (len(B)):
   if B[i]=1: 
     C[i]++, C[i+1]++
e.g.  C = 000000 => 100000 => 111000 => 112100 => 112111

p.s. C[i] = 0, 1 or 2, |C[i]-C[i+1]|<=1

進位
for i in range (len(C)) :
  if C[i] =2:
     C[i] = 0, C[i+1] --
e.g. C = 112111 => 110011

[/quote]
2018-11-26 23:42:30
上面個題鳩做
原理,shift 左一格再加埋一齊
shift 完再加既scenario 得4種,寫曬就得
public int[] solution(int[] A) {
    if (A.length <= 1) {
        return A;
    }
    int[] B = new int[A.length];
    for (int i = 0, j = 1; i < A.length; i++, j++) {
        if (j == A.length) {
            B[i] = A[i];
        } else if (A[i] != A[j]) {
            // 0 1    1 0
            // 1 ? or 0 ?
            B[i] = 1;
        } else if (A[i] == 0) {
            // 0 0
            // 0 ?
            B[i] = 0;
        } else {
            B[i] = 0;
            if (j + 1 == A.length || A[j + 1] == 0) {
                // 1 1
                // 1 0
                B[j] = 0;
            } else {
                // 1 1
                // 1 1
                B[j] = 1;
            }
            i++;
            j++;
        }
    }
    int effectiveIndex = 0;
    for (int i = B.length - 1; i >= 0; i--) {
        if (B[i] == 1) {
            effectiveIndex = i;
            break;
        }
    }
    return Arrays.copyOf(B, effectiveIndex + 1);
}

Online compiler
[url]http://tpcg.io/eSYcyl
[/url]
2018-11-26 23:44:36
加左 test cases 係online compiler 到
time complexity:linear
space complexity:linear
2018-11-27 07:16:37
其實呢唔使幫商家佬諗咁多嘢
請唔到人咪加價囉
唔係你搵咩吸引人入行
除非你係intel咁有名氣
冇人工都一堆人仆去做
賺唔賺到錢係你嘅事
賺到嘅冇問題 賺唔到咪執昱
再者好似你咁講殺出一條血路
都唔代表你有位升啦
香港啲老細
2018-11-27 07:57:40
係server房同人妻扑野
2018-11-27 08:56:23
2018-11-27 08:57:07
識唔識Ctrl c Ctrl v ?
2018-11-27 09:00:09
頂咪貼曲啦 要打J自己打啦好毒
2018-11-27 09:14:03
唔想返工
吹水台自選台熱 門最 新手機台時事台政事台World體育台娛樂台動漫台Apps台遊戲台影視台講故台健康台感情台家庭台潮流台美容台上班台財經台房屋台飲食台旅遊台學術台校園台汽車台音樂台創意台硬件台電器台攝影台玩具台寵物台軟件台活動台電訊台直播台站務台黑 洞