摘要:
题目描述: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- 阅读全文
摘要:
题目描述: Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin 阅读全文
摘要:
题目描述: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume th 阅读全文
摘要:
题目描述: Reverse a singly linked list. Example: Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? 代码实 阅读全文
摘要:
题目描述: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Ex 阅读全文
摘要:
题目描述: 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 t 阅读全文
摘要:
题目描述: Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ 阅读全文
摘要:
题目描述: Given an integer, write a function to determine if it is a power of two. Example 1: Example 2: Example 3: 代码实现: 方法一:用递归的方法做: 方法二:用普通的while循环来做: 阅读全文
摘要:
题目描述: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wik 阅读全文