随笔分类 - Algorithm
classic algorithm, problem
摘要:Follow up for H Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm? Hint:Expected runtime complexity...
阅读全文
摘要:Given an array of citations (each citation is a non negative integer) of a researcher, write a function to compute the researcher's h index.
Accordin...
阅读全文
摘要:>Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exa...
阅读全文
摘要:>Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, ...
阅读全文
摘要:>Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. T...
阅读全文
摘要:>Write a SQL query to find all duplicate emails in a table named Person.```+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d....
阅读全文
摘要:>The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id.```+----+-------+-------...
阅读全文
摘要:>Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.```+----+-------...
阅读全文
摘要:>Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t =...
阅读全文
摘要:>Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:>Integers in each row are sorted ...
阅读全文
摘要:Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k nu...
阅读全文
摘要:>Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except...
阅读全文
摘要:>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 is 1 -> 2 -> 3 ...
阅读全文
摘要:>Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.>According to the definition of LCA on Wikipedia: “The lowe...
阅读全文
摘要:>Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.>For example:>Given n = 13,>Retu...
阅读全文
摘要:>Given a singly linked list, determine if it is a palindrome.>Follow up:>Could you do it in O(n) time and O(1) space?```/** * Definition for singly-li...
阅读全文
摘要:>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 Wikipedi...
阅读全文
摘要:>Reverse bits of a given 32 bits unsigned integer.>For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), retu...
阅读全文
摘要:>Implement the following operations of a queue using stacks.>push(x) -- Push element x to the back of queue.>pop() -- Removes the element from in fron...
阅读全文
摘要:>Given a list of non negative integers, arrange them such that they form the largest number.>For example, given [3, 30, 34, 5, 9], the largest formed ...
阅读全文

浙公网安备 33010602011771号