3.λ.形而下技术博客

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

问题

同事写R程序的时候,问我能不能获取一个变量的name, 我说这个好办啊,在R里可以这样写,用quote()

> a <- 1
> quote(a)
a

不过我把问题想简单了,他实际需要的是要获得传入 参数的name。例如定义一个函数foo(c), 给它传入参数a,我能够在函数 内部知道传入参数的名字a

阅读全文 »

题目概述

原题链接

Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (
not unary) +, -, or * between the digits so they evaluate to the target value.

 "123", 6 -> ["1+2+3", "1*2*3"] 
 "232", 8 -> ["2*3+2", "2+3*2"]
 "105", 5 -> ["1*0+5","10-5"]
 "00", 0 -> ["0+0", "0-0", "0*0"]
 "3456237490", 9191 -> []
阅读全文 »

题目概述

原题链接

Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

Example 1:

11110
11010
11000
00000
Answer: 1

Example 2:

11000
11000
00100
00011
Answer: 3
阅读全文 »
0%