随笔分类 -  LeeCode

摘要:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文
posted @ 2015-07-20 09:16 vpoet 阅读(134) 评论(0) 推荐(0)
摘要:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1 1 /** 2 * Definition for a binary tre... 阅读全文
posted @ 2015-07-20 09:15 vpoet 阅读(202) 评论(0) 推荐(0)
摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr... 阅读全文
posted @ 2015-07-20 09:13 vpoet 阅读(183) 评论(0) 推荐(0)
摘要:Given a linked list, determine if it has a cycle in it. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ... 阅读全文
posted @ 2015-07-20 09:12 vpoet 阅读(135) 评论(0) 推荐(0)
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it hasFor example, the 32-bit integer ’11' has binary representatio... 阅读全文
posted @ 2015-07-20 09:11 vpoet 阅读(163) 评论(0) 推荐(0)
摘要:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is1 -> 2 -> 3 -> ... 阅读全文
posted @ 2015-07-20 09:08 vpoet 阅读(131) 评论(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 an... 阅读全文
posted @ 2015-07-19 21:09 vpoet 阅读(156) 评论(0) 推荐(0)
摘要:Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文
posted @ 2015-07-19 19:47 vpoet 阅读(217) 评论(0) 推荐(0)