基本概念
两学一做
学党章党规、学系列讲话、做合格党员
四讲四有
讲政治,有信念;讲规矩,有纪律;讲道德,有品行;讲风险,有作为
四个全面
全面建成小康社会、全面深化改革、全面依法治国、全面从严治党。
源自于leetcode
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.
For example,
Input: "Hello, my name is John"
Output: 5
计算给定字符串的片段数,片段由空白字符分割。
如给定:"Hello, my name is John", 输出5(五个片段,分别为"Hello,", "my", "name", "is", "John"
源自于leetcode
There are two sorted arrays nums1 and nums2 of size m and n respectively.
Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
Example 1:1
2
3
4nums1 = [1, 3]
nums2 = [2]
The median is 2.0
1 | Example 2: |
给定两个有序数组,长度分别为m和n,找到两个数组的中位数。时间复杂度应该为O(log(m+n))
Elixir中,所有的值都是不可变的。
院子是常量,用于表示某些东西的名字,以冒号(:)开头
元组被创建就无法修改,如:
{1, 2}
用于模式匹配
1
2
3
4
5
6
7
8
9 iex(4)> {status, count, action} = {:ok, 42, "next"}
{:ok, 42, "next"}
iex(5)> status
:ok
iex(6)> count
42
iex(7)> action
"next"
iex(8)>
1 | iex(9)> states = %{"AL" => "Alabama", "WI" => "Wisconsin"} |
1 | iex(1)> sum = fn (a, b) -> a + b end |
函数重载取决于传入的参数类型和内容,通过模式匹配来选择要运行的子句
1 | iex(1)> handle_open = fn |
源自于leetcode
Given a string, find the length of the longest substring without repeating characters.
Examples:
Given "abcabcbb", the answer is "abc", which the length is 3.
Given "bbbbb", the answer is "b", with the length of 1.
Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring, "pwke" is a subsequence and not a substring.
给定一个字串,返回最长不包含重复字符的子串。如"abcabcbb"的最长不包含重复字符的子串为“abc”,“bca”`等,长度都为3
题目出处:leetcode
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution.
Example:1
2
3
4Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
根据request的format参数来确定返回值类型,代码如下:
1 | respond_to do |format| |
链接地址:
1 | <%= link_to('Download Link', {:action => :download, :format => :csv}) %> |
添加CSV模板文件,命名为<action_name>.csv.erb