码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 力扣bash


    192.统计词频
    https://leetcode.cn/problems/word-frequency/solution/qie-ge-pai-xu-dan-ci-tong-ji-ci-shu-pai-8sdgt/

    # Read from the file words.txt and output the word frequency list to stdout.
    cat words.txt | tr -s ' ' '\n' | sort | uniq -c | sort -r | awk '{ print $2, $1 }'
    
    • 1
    • 2

    193.有效电话号码
    (xxx) xxx-xxxx 或 xxx-xxx-xxxx。(x 表示一个数字)
    https://leetcode.cn/problems/valid-phone-numbers/solution/zheng-ze-biao-da-shi-zhong-xian-ding-fu-yu-ding-we/

    # Read from the file file.txt and output all valid phone numbers to stdout.
    gawk '/^([0-9]{3}-|\([0-9]{3}\) )[0-9]{3}-[0-9]{4}$/' file.txt
    
    • 1
    • 2

    194.转置文件
    给定一个文件 file.txt,转置它的内容
    https://leetcode.cn/problems/transpose-file/solution/194-chao-97de-wcawkxargsjie-fa-by-ffretu-a469/

    # Read from the file file.txt and print its transposed content to stdout.
    # 获取第一行,然后用wc来获取列数
    COLS=`head -1 file.txt | wc -w`
    # 使用awk依次去输出文件的每一列的参数,然后用xargs做转置
    for (( i = 1; i <= $COLS; i++ )); do
        # 这里col就是在代码里要替换的参数,而它等于$i
        awk -v col=$i '{print $col}' file.txt | xargs
    done
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    195.第十行
    给定一个文本文件 file.txt,请只打印这个文件中的第十行。
    https://leetcode.cn/problems/tenth-line/solution/shuang-bai-jie-da-by-ffreturn-68bk/

    # Read from the file file.txt and output the tenth line to stdout.
    # Read from the file file.txt and output the tenth line to stdout.
    sed -n "10p" file.txt
    
    • 1
    • 2
    • 3
  • 相关阅读:
    3-SpringBoot架构设计与实现原理-自动装配底层原理和手写自动装配
    Vue2 +Element UI 表格行合并
    【Linux网络】UdpSocket
    经典论文阅读之-GICP(ICP大一统)
    QCC51XX---BLE_生活中的实例_医院的结构
    4 vCPU 实例达成 100 万 JSON API 请求/秒的优化实践
    数据分享|R语言逻辑回归、线性判别分析LDA、GAM、MARS、KNN、QDA、决策树、随机森林、SVM分类葡萄酒交叉验证ROC...
    《剑指 Offer》专项突破版 - 面试题 79 ~ 84 : 详解回溯法(C++ 实现)
    LeetCode220802_67、三数之和
    pmm最新版本v2.40.0尝鲜体验
  • 原文地址:https://blog.csdn.net/cx_cs/article/details/126436344
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号