摘要:
Question:Sort a linked list inO(nlogn) time using constant space complexity.Analysis:问题描述:在O(nlogn)时间内用常数的空间复杂度,完成一个链表的排序。思考:排序时间复杂度为O(nlogn)的话,快排、堆排序... 阅读全文
摘要:
Question:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the fa... 阅读全文
摘要:
Question:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wi... 阅读全文
摘要:
Question:Write a program to find then-th ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For example,1, 2, 3, 4... 阅读全文
摘要:
Question:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. ... 阅读全文
摘要:
Question:Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For exampl... 阅读全文
摘要:
Question:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may c... 阅读全文
摘要:
Question:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may c... 阅读全文