摘要: Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length. class Solution {public: int removeElement(int A[], int n, int elem) { // Start typing your C/C++ ... 阅读全文
posted @ 2013-04-24 17:04 冰点猎手 阅读(272) 评论(0) 推荐(0)
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ 2 2 \ \ 3 3Note:Bonus points if you could solve it both recursive... 阅读全文
posted @ 2013-04-24 12:36 冰点猎手 阅读(135) 评论(0) 推荐(0)
摘要: Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of elements initialized in A and B are m and n respectively. class Solution {public: void merge(int A[], int m, int B[], int n) {... 阅读全文
posted @ 2013-04-24 12:10 冰点猎手 阅读(146) 评论(0) 推荐(0)
摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class ... 阅读全文
posted @ 2013-04-24 11:58 冰点猎手 阅读(151) 评论(0) 推荐(0)
摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are 阅读全文
posted @ 2013-04-17 23:56 冰点猎手 阅读(164) 评论(0) 推荐(0)
摘要: 最近做raycasting,由于体数据比较大,超过了3D纹理的限制,所以需要查询3d纹理(GL_MAX_3D_TEXTURE_SIZE)范围限制。使用了以下函数: glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &maxsize ); 这里有对于OpenGL 参数以及极限等等查询函数的详解 http://www.opengl.org/sdk/docs/man/xhtml/glGet.xml 阅读全文
posted @ 2013-04-17 20:32 冰点猎手 阅读(356) 评论(0) 推荐(0)
摘要: Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value./** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * ... 阅读全文
posted @ 2013-04-16 18:19 冰点猎手 阅读(111) 评论(0) 推荐(0)
摘要: 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 keys less than the node's key.The right subtree of a node contains only nodes with keys greater than the node's key.Both the left an 阅读全文
posted @ 2013-04-16 18:06 冰点猎手 阅读(137) 评论(0) 推荐(0)
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \... 阅读全文
posted @ 2013-04-14 14:04 冰点猎手 阅读(140) 评论(0) 推荐(0)
摘要: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val... 阅读全文
posted @ 2013-04-14 13:33 冰点猎手 阅读(181) 评论(0) 推荐(0)