• done apple经理面 匹配括号但是不能用stack


    一个感想:面试真是有效学习的唯一途径。面试前觉得自己啥都会,面完了才发觉自己是个知识有漏洞的傻逼。

    有面试才有学习机会,先拿到面试,之后啥都好说。

    {[abc]}[ab]{}
    no stack, use loop
    一开始抄了一个c++的答案错了,cnm。。。血的教训:不要抄别的语言的答案!
    后来抄了一个只有括号的答案,要改,时间来不及了。。

     

    from Abhishek Shukla (Apple) to Everyone:    12:15  PM
    public class A {
        protected A() {
            print("inside A");
        }
    }
    public class B extends A {
        protected B() {
            print("inside B");
        }
        
        main () {
            A a = new B();
        }
    }
    from Abhishek Shukla (Apple) to Everyone:    12:18  PM
    =======================
    from Abhishek Shukla (Apple) to Everyone:    12:18  PM
    Class A {
        void method1(int i){
            print("inside A.method1");
        }
    }
    
    
    Class B extends A {
        void method1(int i){
            print("inside B.method1 with int");
        }
        
        void method1(String s){
            print("inside B.method1 with String");
        }
        
        main () {
            A a = new B();
            a.method1(10);
        }
    }
    from Abhishek Shukla (Apple) to Everyone:    12:21  PM
    ======================
    from Abhishek Shukla (Apple) to Everyone:    12:21  PM
    public class Myclass {
       private static Integer INT = new Integer(10);
        public synchronized void methodA () {
            print("Inside method A")
        }
        public synchronized static void methodB () {
            print("Inside method B")
        }
    }
    
    from Abhishek Shukla (Apple) to Everyone:    12:15  PM
    public class A {
        protected A() {
            print("inside A");
        }
    }
    public class B extends A {
        protected B() {
            print("inside B");
        }
        
        main () {
            A a = new B();
        }
    }
    from Abhishek Shukla (Apple) to Everyone:    12:18  PM
    =======================
    from Abhishek Shukla (Apple) to Everyone:    12:18  PM
    Class A {
        void method1(int i){
            print("inside A.method1");
        }
    }
    
    
    Class B extends A {
        void method1(int i){
            print("inside B.method1 with int");
        }
        
        void method1(String s){
            print("inside B.method1 with String");
        }
        
        main () {
            A a = new B();
            a.method1(10);
        }
    }
    
    
    
    
    
    
    
    
    
    from Abhishek Shukla (Apple) to Everyone:    12:15  PM
    
    public class A {
        protected A() {
            print("inside A");
        }
    }
    public class B extends A {
        protected B() {
            print("inside B");
        }
        
        main () {
            A a = new B();
        }
    }
    import java.util.*;
    
    public class MyClass {
        
        public static void main(String args[]) {
          String s = "{[abc]}[ab]{}";
          boolean result = "true";
          
          //use array
          char[] array = s.toCharArray();
          
          int pointer = 0;
          char[] helper = new char[array.length];
    
           //for loop 
           for (char c: array) {
               if (c == '(') helper[pointer++] = ')';
               else if (c == '{') helper[pointer++] = '}';
               else if (c == '[') helper[pointer++] = ']';
               
               //check 
               else if (pointer == 0 || helper[--pointer] != c) {
                   result = "false";
               }
           }
           
          //judge if pointer can always be 0
          if (pointer == 0) 
            System.out.println("true");
          else
            System.out.println("false");
          
        }
    }
        //time:n, space:n
        

     

  • 相关阅读:
    Class 'ViewCell' has no initializers
    xcode:关于Other Linker Flags
    NSString编码形式是UTF–16
    手写识别方案汇总
    将一个 view 进行截图
    程序员最核心的竞争力是什么?
    sqlite3
    创建NAT 64网络
    Snagit安装步骤
    cnblogs插件jiathis
  • 原文地址:https://www.cnblogs.com/immiao0319/p/15350982.html
Copyright © 2020-2023  润新知