3.λ.形而下技术博客

这里只关注技术实现,用代码说话。

问题

Java世界里构建项目用什么工具呢,ant,maven和gradle。maven非常流行, 原因无非是maven仓库和项目架构的约定。但是ant构建过程更加容易理解, 因为ant展示了所有的操作。gradle拥有基于groovy语言的DSL语言且继承了 maven仓库的思想所以笔者认为未来是属于gradle的。

阅读全文 »

MiniLisp是什么?

MiniLisp是一个只用几百行代码实现的Lisp。以下是实现的 基本特性。

  • integers, symbols, cons cells,
  • global variables,
  • lexically-scoped local variables,
  • closures,
  • if conditional,
  • primitive functions, such as +, =, <, or list,
  • user-defined functions,
  • a macro system,
  • and a copying garbage collector.
阅读全文 »

题目概述

原题链接

Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.

Examples: 
 `[2,3,4]` , the median is 3

 `[2,3]`, the median is (2 + 3) / 2 = 2.5

Design a data structure that supports the following two operations:

- void addNum(int num) - Add a integer number from the data stream to the data structure. 
- double findMedian() - Return the median of all elements so far.   
For example:

addNum(1)
addNum(2)
findMedian() -> 1.5
addNum(3) 
findMedian() -> 2
阅读全文 »

Cython

Cython不是CPython的简称,而是一种提升Python代码执行效率的解决方案。 据说一般达到30x。一会我们来看看是不是真的。这个技术对老鸟来说已经是好多 年前的了。但是很多情况下python用户真的用不上,所以不知道也无妨。

阅读全文 »

题目概述

原题链接

Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.
Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j (i ≤ j), inclusive.

Example:
Given nums = [-2, 5, -1], lower = -2, upper = 2,
Return 3.
The three ranges are : [0, 0], [2, 2], [0, 2] and their respective sums are: -2, -1, 2.
阅读全文 »

题目概述

原题链接

You are given an integer array nums and you
have to return a new counts array. 
The counts array has the property where counts[i] is 
the number of smaller elements to the right of nums[i].

Example:

Given nums = [5, 2, 6, 1]

To the right of 5 there are 2 smaller elements (2 and 1).
To the right of 2 there is only 1 smaller element (1).
To the right of 6 there is 1 smaller element (1).
To the right of 1 there is 0 smaller element.
Return the array [2, 1, 1, 0].
阅读全文 »
0%