LeetCode 刷题
gemtra
希望输出点有价值的东西
展开
-
LeetCode-195-第十行
给定一个文本文件 file.txt,请只打印这个文件中的第十行。 示例: 假设 file.txt 有如下内容: Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Line 9 Line 10 你的脚本应当显示第十行: Line 10 说明: 如果文件少于十行,你应当输出什么? 至少有三种不同的解法,请尝试尽可能多的方法来解题。 ...原创 2019-11-23 22:40:34 · 93 阅读 · 0 评论 -
LeetCode-193-有效电话号码
给定一个包含电话号码列表(一行一个电话号码)的文本文件 file.txt,写一个 bash 脚本输出所有有效的电话号码。 你可以假设一个有效的电话号码必须满足以下两种格式: (xxx) xxx-xxxx 或 xxx-xxx-xxxx。(x 表示一个数字) 你也可以假设每行前后没有多余的空格字符。 示例: 假设 file.txt 内容如下: 987-123-4567 123 456 7890 (12...原创 2019-11-23 22:30:45 · 140 阅读 · 0 评论 -
LeetCode-192-Word Frequency
Write a bash script to calculate the frequency of each word in a text file words.txt. For simplicity sake, you may assume: words.txt contains only lowercase characters and space ’ ’ characters. Each ...原创 2019-11-23 22:15:26 · 116 阅读 · 0 评论 -
LeetCode-194-Transpose File
Given a text file file.txt, transpose its content. You may assume that each row has the same number of columns and each field is separated by the ’ ’ character. Example: If file.txt has the following ...原创 2019-11-23 22:05:50 · 99 阅读 · 0 评论