
go
AAAAAAAIXX
这个作者很懒,什么都没留下…
展开
-
Go语言中的闭包
基本概念闭包是可以包含自由(未绑定到特定对象)变量的代码块,这些变量不在这个代码块内或者任何全局上下文中定义,而是在定义代码块的环境中定义。要执行的代码块(由于自由变量包含在代码块中,所以这些自由变量以及他们引用的对象没有被释放)为自由变量提供绑定的计算环境(作用域)。闭包的价值闭包的价值在于可以作为函数对象或者匿名函数,对于类型系统而言,这意味着不仅要表示数据还要表示代码。支持闭包的多数语言都将函原创 2017-01-12 16:13:51 · 517 阅读 · 0 评论 -
golang-new与make
作者:YY哥 出处:http://www.cnblogs.com/hustcat/ Go语言中的内建函数new和make是两个用于内存分配的原语(allocation primitives)。对于初学者,这两者的区别也挺容易让人迷糊的。简单的说,new只分配内存,make用于slice,map,和channel的初始化。new 这是一个用来分配内存的内建函数,但是与C++不一样的是,它并不初转载 2017-05-10 10:13:50 · 404 阅读 · 0 评论 -
21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.排序链表归并package leet//Definition for singly-linked list.type原创 2017-05-10 10:04:31 · 444 阅读 · 0 评论 -
20. Valid Parentheses
Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets must close in the correct order, “()” and “()[]{}” are all valid but “原创 2017-05-10 09:34:08 · 411 阅读 · 0 评论 -
14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 找到string数组的相同的字符串前缀java:public class Solution { public String longestCommonPrefix(String[] strs) {原创 2017-04-25 18:19:57 · 389 阅读 · 0 评论 -
19. Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked原创 2017-05-05 13:36:11 · 505 阅读 · 0 评论 -
17. Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string “23原创 2017-05-03 19:17:18 · 397 阅读 · 0 评论 -
golang 常见用法集合
获取string字符串长度 //字符串中字符全为ASCII中的字符 len(str) //字符串中含非ASCII的Unicode字符 utf8.RuneCountInString(str)string转int //string到int int,err:=strconv.Atoi(string) //string到int64原创 2017-05-03 17:59:44 · 1956 阅读 · 0 评论 -
16. 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly原创 2017-05-03 17:33:06 · 411 阅读 · 0 评论 -
15. 3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain duplic原创 2017-05-03 11:42:06 · 424 阅读 · 0 评论 -
22.Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is: [ “((()))”, “(()())”, “(())()”, “()(())”,原创 2017-06-06 11:12:49 · 514 阅读 · 0 评论