First Amazon Phone Interview

  1. Introduce the android application you did.

  2. the project you did fun

  3. right you are wrong

  4. what is content provider

  5. what is intent

coding:

  1. isValidPalindrome demo

public boolean isValid(String s){
    if(s == null) return true;
    int left = 0, right = s.length()-1;
    while(left < right){
        if(s.charAt(left) != s.charAt(right)) return false;
        left++;
        right--;
    }
    return false;
}

2. binary tree: has at most two tree node

L110 balanced binary tree

why + 1: we need to add current root's height;

public boolean isBalanced(TreeNode root){
    if(root == null) return true;
    int left = getHeight(root.left);
    int right = getHeight(root.right);
    return Math.abs(left - right) <= 1 && 
    isBalanced(root.left) && isBalanced(root.right);
}
private int getHeight(TreeNode root){
    if(root == null) return 0;
    int left = getHeight(root.left);
    int right = getHeight(root.right);
    return Math.max(left,right)+1;
}

3. ood design 扑克牌

Last updated

Was this helpful?