Coding Rabbit


  • 首页

  • 关于

  • 归档

  • 标签

  • 搜索

Number of Boomerangs || Linked List Cycle Series

发表于 2016-12-06
Number of BoomerangsQuestionGiven n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters). Find the number of boomerangs. You may assume that n will ...
阅读全文 »

Insert Interval/ Merge Intervals

发表于 2016-11-30
Insert IntervalQuestionGiven a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Example 1:Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9]. Exa ...
阅读全文 »

Unique Path Series

发表于 2016-11-14
Unique Paths IQuestionA robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below). How many ...
阅读全文 »

Binary Search Tree Iterator || Binary Tree Zigzag Level Order Traversal

发表于 2016-10-29
Binary Search Tree IteratorQuestionImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Note: next() and hasNext() should run in average O(1) time and uses O(h) memory, wh ...
阅读全文 »

Word Break || Word Break II

发表于 2016-10-27
Word BreakQuestionGiven a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, givens = "leetcode",dict = ["leet", "code"]. Return true because "leetcode" can be ...
阅读全文 »

Rotate Function

发表于 2016-10-24
Rotate FunctionQuestionGiven an array of integers A and let n to be its length. Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a “rotation function” F on A as follow: F(k) = 0 * Bk[0] + 1 * Bk[1] + ... + (n-1) * Bk[n-1]. Calculate the maximum value of F(0 ...
阅读全文 »

Best Time to Buy and Sell Stock

发表于 2016-10-18
Best Time to Buy and Sell StockQuestionSay you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit. Example 1: 1234 ...
阅读全文 »

Search a 2D Matrix || Search a 2D Matrix II

发表于 2016-10-16
Search a 2D MatrixQuestionWrite 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 from left to right. The first integer of each row is greater than the last integer of the previous row. For example, Consid ...
阅读全文 »

Find Minimum in Rotated Sorted Array || Search in Rotated Sorted Array || Search in Rotated Sorted Array II

发表于 2016-10-14
Find Minimum in Rotated Sorted ArrayQuestionSuppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. You may assume no duplicate exists in the array. Analysis Compact and clean C++ solution left<right ...
阅读全文 »

H-Index Series

发表于 2016-10-12
H-IndexQuestionGiven an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index. According to the definition of h-index on Wikipedia: “A scientist has index h if h of his/her N papers have at least h citations each, and the o ...
阅读全文 »
1…456…8
Coding Rabbit

Coding Rabbit

77 日志
37 标签
RSS
Github Facebook weibo
Links
  • Codeboy
  • Yijia_Jin
© 2017 Coding Rabbit
由 Hexo 强力驱动
主题 - NexT.Mist