摘要:
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keysless thanthe node's key.The right subtree of a node contains only nodes with keysgreater thanthe node's key.Both the left and ri 阅读全文
摘要:
You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?Solution: 1 void rotate(vector > &matrix) { 2 int n = matrix.size(); 3 for(int i = 0; i < n / 2; i ++) { 4 for(int j = i; j < n - 1 - i; ... 阅读全文