聚合国内IT技术精华文章,分享IT技术精华,帮助IT从业人士成长

  • 1410136 views阅读

    Simple Python code of Knapsack Problem

    Just write this snippet for my practice of 0-1 Knapsack Problem: values = [1, 2, 3, 4, 5] weights = [3, 2, 1, 9, 6] max_weight = 12 def knappack(): n = len(values) dp = [[0] * (max_weight+1)...

    分类:技术文章 时间:2023-06-23 14:45 我要评论(0个)

  • 1657265 views阅读

    Use bits instead of set for visited nodes. LeetCode #1434

    My first idea is depth-first-search: iterate all people, try to give them different hats. The solution got TLE (Time Limit Exceeded). Then as a hint from discussion forum, I started to iterate hat...

    分类:技术文章 时间:2023-03-22 12:39 我要评论(0个)

  • 1844587 views阅读

    Effectively fetch the smallest element in a heap of Python

    To solve Leetcode #1675, I wrote the below code with the help of hints: import sys import heapq class Solution: def minimumDeviation(self, nums: List[int]) -> int: n = len(nums) heapq.he...

    分类:技术文章 时间:2023-02-24 19:07 我要评论(0个)

  • 1789144 views阅读

    A tip for the time complexity of LeetCode #127

    The first intuitive idea that jumps out of my mind after taking a look at LeetCode #127 is using the graph algorithm. But for building the graph first, I need to traverse the wordList by O(n2) tim...

    分类:技术文章 时间:2023-02-17 10:34 我要评论(0个)

  • 1913352 views阅读

    Divide and Conquer solution for LeetCode #494

    The popular solution for LeetCode #494 is dynamic programming. But my first idea is Divide and Conquer. Although it’s not very fast, it’s another idea: from collections import Count...

    分类:技术文章 时间:2023-02-10 10:35 我要评论(0个)

  • 2676583 views阅读

    A wrong way to solve

    About two weeks ago I met the “number of islands” problem in LeetCode. The first idea that jumped out of my brain is ‘dynamic programming’: I can create a new matrix (let&#...

    分类:技术文章 时间:2022-01-28 13:45 我要评论(0个)

  • 3181765 views阅读

    Python code for the sequence partition problem (using NumPy)

    Imagine we have an array of numbers [9, 8, 7, 1, 2, 3, 4, 5, 6]. What’s the best solution to split it into 3 partitions with the most “average sum”, which means they have minimum...

    分类:技术文章 时间:2021-11-12 09:51 我要评论(0个)

  • 2503301 views阅读

    Python code for the n-queens problem (using NumPy)

    I am reading the second edition of “The Algorithm Design Manual” recently. Reaching the chapter about backtracking, I realized that this method could solve many problems, even complica...

    分类:技术文章 时间:2021-11-05 09:51 我要评论(0个)

  • 3790218 views阅读

    使用 fastText 做中文文本分类(2)

    查看本系列文章合集,请看这里。 做好文本预处理,才能输入fastText训练一个效果好的模型出来。 ✓ 原文示例 有时我们拿到的源数据是很粗糙的,带有很多会影响模型效果的内容,例如下面这样: <p>罗望子,是豆科酸豆属唯一的种,是热带乔木,原产于东部非洲,包括马达加斯加落叶森林,但已被引入热带亚洲、拉丁美洲和加勒比海。柽柳是中国海南省三亚的一种城市树木。罗望子最适...

    分类:技术文章 时间:2020-07-29 21:02 我要评论(0个)

  • 4129697 views阅读

    使用 fastText 做中文文本分类(3)

    查看本系列文章合集,请看这里。 为 training 数据做标注,这可能是一个艰巨的任务,也可能是一个有捷径的任务。 有时候,我们可以依据一些已知的规则来标注文本,比如不同的数据是从不同的来源获取到的,从来源可以知道它们所属的类别,这是一个捷径。不过我这里不具备这样的条件。 我的数据来源是网上的各种新闻,不是某些专业领域的数据,这种比较常见的文本分类任务,可以利用国内的几大云服务商提供的免...

    分类:技术文章 时间:2020-07-29 21:02 我要评论(0个)

  • 3446104 views阅读

    使用 fastText 做中文文本分类(4)

    查看本系列文章合集,请看这里。 ✓ 开始训练第一个文本分类模型 标注好的数据,其格式为: __label__科技 月 10 日 网通 社从 高合 汽车 获悉 华人 运通 微软 2020 世界 人工智能 大会 云端 峰会 WAIC 2020 上 达成 战略 合作 依托 微软 小冰 人工智能 技术 高合 汽车 上 落地 全球 首个 主动式 人工智能 伙伴 HiPhiGo 用户...

    分类:技术文章 时间:2020-07-29 21:02 我要评论(0个)

  • 4724494 views阅读

    使用 fastText 做中文文本分类(5)

    查看本系列文章合集,请看这里。 前面说的模型训练、预测过程,是用 fastText 可执行程序完成的。fastText提供了Python的接口,同样的功能也可以用Python实现。如果数据量比较小,单机做文本分类没啥问题。但我的数据量比较大,几十G的文本数据,单机加载模型、预测分类太耗资源了,而且速度慢。 并行这种事嘛,交给Map-Reduce job来做是最合适不过了,不过,要在Hado...

    分类:技术文章 时间:2020-07-29 21:02 我要评论(0个)