Tag: 算法与数据结构基础


  1. 每周一算法2018.02.09

    Can Place Flowers Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die. Given a flowerbed (represented as …

    算法与数据结构基础继续阅读

  2. 每周一算法2018.02.02

    Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too. You need to find the shortest such subarray and output its length…

    算法与数据结构基础继续阅读

  3. 每周一算法2018.01.26

    Average of Levels in Binary Tree SGiven a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: Output: [3, 14.5, 11] Explanation: The average value of nodes on level 0 is 3, on …

    算法与数据结构基础继续阅读

  4. 每周一算法2018.01.19

    Fizz Buzz Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both…

    算法与数据结构基础继续阅读

  5. 每周一算法2018.01.12

    Arranging Coins You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number of full staircase rows that can be formed. n is a non-negative integer and fit…

    算法与数据结构基础继续阅读

  6. 每周一算法2018.01.05

    Longest Palindrome Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This is case sensitive, for example "Aa" is not considered a palindrome here. Note…

    算法与数据结构基础继续阅读

  7. 每周一算法2017.12.29

    Best Time to Buy and Sell Stock Say 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 algorit…

    算法与数据结构基础继续阅读