9.4 perl review+5道leetcode

9.4

1.perl review

  • $string
  1. 定义用my:my $str =“./ file.txt”;
  2. 打开file的句柄,并导入$:open my $IN, ‘<’, $in or die;

   3. 拼接string:$sr=$sr.$j

  • @arr 
  • 1.shift
  • $element=shift (@data)

1.@data 的第一个元素被剥除了

2.$element 可接收pop出来的

  • foreach my $j(@data);

  • @ARGV

what? perl 自带的array,不需要用my 

Why? 人perl 互换,从command line得到数据

how?$n1=$ARGV[0];

  • 如何访问@的string元素? 

$ARGV[0]

  • my $data=<STDIN>

What? 

<> read line operator 

why? 

人perl 交互,从command line得到数据

how?

@ARGV = ("aaa","bbb","ccc");

 while (<>) { # process files aaa, bbb, and ccc 

print "this line is: $_"; 

}

  • %data=(‘A’, 45, ‘B’,30)

If ($line=~m/Pattern/)

{

my @column=split(‘’ , $line);

print “$column[2]”;

print “Before: $`\n”; 前 

print “Matched: $&\n”;

print “After: $’\n”; //后

}

$sr=~s/failed/NaN/g;

 $i eq $j;

chop($kok);// remove the last character from input string

=========

第一道

205 

1. 用hash存char和index 

2.构造一个list,将char,替换成这个char第一次出现的index

第二道

219 

单纯地用sliding window会导致timeout

hash_tab好

第三道

228 

如何初跑即过?

1.str/int: str和int的格式一致

2.if/else: if and else 的完备性

3.指针: 同?+边界

4.range:nums[i] 和 i的区别

5.array:len(nums)==0?

第四道

1275

列表生成式法

test = [[-3 for i in range(m)] for j in range(n)]

第五道

235 

脑袋想破了的2小时,最后,binary search tree(BST)==ordered 

左边小,右边大

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值