摘要: 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 阅读全文
posted @ 2013-11-26 14:28 假日笛声 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 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; ... 阅读全文
posted @ 2013-11-26 13:25 假日笛声 阅读(527) 评论(0) 推荐(0) 编辑