摘要:
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 n... 阅读全文
摘要:
Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor... 阅读全文
摘要:
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.You m... 阅读全文
摘要:
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?题目大意:给定一个链表,判断是否有环?解题思路:解法一:快慢指针,如果有环,那么快慢... 阅读全文
摘要:
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文