PureStorage OA, 只有两道coding

直接海投 software engineer - flash blade ,收到purestorage的OA。看地里的面经,都是8或9或12题,自行考古,很详细。我收到的测试为dev tools,只有两
题,只有两题,只有两题,比较简单。。。
一道是count how many substring can be a palindrom in a input string, leetcode原题
一道是,给一个文件有历史访问记录,每一行为一条记录,提起记录中有过同一时间多次访问的timestamp
找工作开始得比较晚,到现在还在折腾。转行伤不起,继续加油。

果然是白嫖。OA后,recruiter电话了解情况后安排店面。日程都发了,然后告知position filled


第二题可以用delimiter嘛? ’\t’?

不用,input都是一行,然后找中间的timestamp就行


楼主加油。。。DEV TOOL的OA很怪的,不过组员真的很好。如果你是6月底安排的电面就应该不是白嫖。。。应该是我跟HR拖
着的原因。。

听很多人说,purestorage氛围很好。
应该不是拖着了,先是安排电面,然后没消息,发邮件给recruiter问,拒信就来了。
你在purestorage?下次求求内推啊,谢谢。
继续加油吧。

The question was about checking if the given sequence of events is valid. The conditions are:
The order of release should be reverse of aquiring(stack)
A locked lock can not be aquired again
A lock has to be locked before releasing
There should be no dangling locks

	    // Complete the check_log_history function below.
    static int check_log_history(List<String> events) {
        HashSet<Integer> hs = new HashSet();
        Stack<Integer> st = new Stack();
        for(int i = 0; i < events.size(); i++){
            String e = events.get(i);
            String name = e.split(" ")[0];
            int num = Integer.parseInt(e.split(" ")[1]);
            if(name.equals("ACQUIRE")){
                if(hs.contains(num)){
                    return i+1;
                } 
                st.push(num);
                hs.add(num);
            }else{
                if(!hs.contains(num) || st.peek() != num){
                    return i+1;
                }
                st.pop();
                hs.remove(num);
            }     
        }
        return st.empty() ? 0 : events.size()+1;

    }

Find the score for each number, you got points for:
+1 for number divisible by 7
+2 for even digits
+4 for each 9
+5 for 2 consecutive 1 and +5 for each consecutive followine one
+N2 for every continous sequnce of the form 123 or 4567 of length N

This code fails for just one case, not sure why!

    // Complete the compute_number_score function below.
    static int compute_number_score(int number) {
        if(number==0){
            return 2;
        }
        // System.out.println( getDigitWiseScore(number)  + " "  + countConsecutiveOnes(number) +" " +get(number));
        return getDigitWiseScore(number)  + countConsecutiveOnes(number) +get(number);

    }
    public static int getDigitWiseScore(int num){
        int score = 0;
        if(num%7==0) score+=1;
        while(num>0){
            int d = num%10;
            if(d==9) score+=4;
            if(d%2==0) score+=2;
            num = num/10;
        }
        return score;
    }
    public static int countConsecutiveOnes(int num){
        int score =0;
        int currentOnes = 0;
        while(num > 0 ){
            int d = num%10;
            num = num/10;
            if(d!=1 && currentOnes > 1 ){
                score+=5;
                score += (currentOnes-2)*5;
                currentOnes = 0;
            }
            if(d==1){
                currentOnes++;
            }
        }
        if(currentOnes> 1){
            score+=5;
            score += (currentOnes-2)*5;
        }
        return score;
    }
    public static  int getSeq(int num){
        String s = Integer.toString(num);
        int score=0;
        int pointer = 1;
        int current = 1;
        int previous = s.charAt(0);
        while(pointer< s.length()){
            if(s.charAt(pointer) == previous){
                current++;
                previous++;
            } else if( current > 1 && s.charAt(pointer) != previous+1 ){
                score = score+ (current*current);
                current =01;
                score = score+1;
            } else{
                score = score+1;
            } 
            
            previous = s.charAt(pointer);
            pointer++;
        }
        return score;
    }

    public static int get(int num) {
        int x=0, count=1;
        List<Integer> store = new ArrayList<>();
        String s = Integer.toString(num);
        while(x<s.length()-1) {
            if (s.charAt(x)+1 == s.charAt(x+1)){
                count ++;
                x++;
            }
            else {
                x++;
                store.add(count);
                count = 1;
            }
        }
        store.add(count);
        int score = 0;
        for(Integer i: store){
            score += i*i;
        }
        return score;

    }

只有第7题有数字上的改动。对于第二条consecu tive pair,感觉example写的不太对,按照4个连续的5加9分可以过全部的test case。