随笔分类 -  算法题

摘要:Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given 阅读全文
posted @ 2019-06-30 13:05 小白兔云 阅读(127) 评论(0) 推荐(0)
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the 阅读全文
posted @ 2019-06-30 09:47 小白兔云 阅读(195) 评论(2) 推荐(0)
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced bina 阅读全文
posted @ 2019-06-18 15:09 小白兔云 阅读(137) 评论(0) 推荐(0)
摘要:A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The 阅读全文
posted @ 2019-06-15 10:35 小白兔云 阅读(159) 评论(0) 推荐(0)
摘要:Given a non-empty array of integers, return the k most frequent elements. Example 1: Example 2: Input: nums = [1], k = 1 Output: [1] Example 2: Note: 阅读全文
posted @ 2019-06-13 10:11 小白兔云 阅读(163) 评论(0) 推荐(0)
摘要:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum pro 阅读全文
posted @ 2019-05-24 18:06 小白兔云 阅读(114) 评论(0) 推荐(0)
摘要:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and r 阅读全文
posted @ 2019-05-24 13:58 小白兔云 阅读(138) 评论(0) 推荐(0)
摘要:Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tick 阅读全文
posted @ 2019-05-23 11:51 小白兔云 阅读(145) 评论(0) 推荐(0)
摘要:The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each hou 阅读全文
posted @ 2019-05-23 11:09 小白兔云 阅读(124) 评论(0) 推荐(0)
摘要:Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally the function should: Note: Your algo 阅读全文
posted @ 2019-05-23 10:17 小白兔云 阅读(129) 评论(0) 推荐(0)
摘要:Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Example 1: Example 2: Note: You may assume all input has 阅读全文
posted @ 2019-05-22 14:58 小白兔云 阅读(116) 评论(0) 推荐(0)
摘要:One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, 阅读全文
posted @ 2019-05-22 12:40 小白兔云 阅读(146) 评论(0) 推荐(0)
摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文
posted @ 2019-05-22 10:32 小白兔云 阅读(133) 评论(0) 推荐(0)
摘要:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee 阅读全文
posted @ 2019-05-21 11:44 小白兔云 阅读(145) 评论(0) 推荐(0)
摘要:There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every 阅读全文
posted @ 2019-05-21 10:16 小白兔云 阅读(146) 评论(0) 推荐(0)
摘要:Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assum 阅读全文
posted @ 2019-05-21 09:39 小白兔云 阅读(133) 评论(0) 推荐(0)
摘要:For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible root 阅读全文
posted @ 2019-05-20 11:42 小白兔云 阅读(223) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2019-05-20 10:32 小白兔云 阅读(192) 评论(0) 推荐(0)
摘要:Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes 阅读全文
posted @ 2019-05-19 23:36 小白兔云 阅读(126) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies nums by upd 阅读全文
posted @ 2019-05-18 20:39 小白兔云 阅读(136) 评论(0) 推荐(0)