![](https://img-blog.csdnimg.cn/20190927151026427.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
数据结构与算法
文章平均质量分 61
理解数据结构与算法,并灵活将其应用于实际问题。
胡小白的数据科学之路
https://www.zhihu.com/people/hu-jia-hao-10-2
展开
-
Leetcode 205题:Isomorphic Strings
题目描述给定两个字符串,检查它们是否是结构相似的。对于结构相似的定义如下Two strings s and t are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters m原创 2021-09-15 17:00:03 · 164 阅读 · 0 评论 -
Leetcode 203题:Remove Linked List Elements
题目描述这是一道关于链表的题目,原题如下Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.稍微做个说明:给定一个值val,删除链表中值等于该val的所有节点,返回新链表的head节点。对于链表的删除操作,我们需要知道该节点的上一个节点的信息和下一个节点的信息。但是给定原创 2021-09-13 13:36:54 · 102 阅读 · 0 评论 -
Leetcode 202题:Happy Number的2种解法
题目描述确定某个数n是否是happy number。关于happy number的定义如下:Starting with any positive integer, replace the number by the sum of the squares of its digits.Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does原创 2021-09-12 12:51:45 · 387 阅读 · 0 评论 -
Leetcode 191题:Number of 1Bits 的两种解法
题目描述给定一个32位的无符号整数(unsigned integer),求出有几位值为1。貌似这个问题也被称做Hamming weight,anyway,下面来说一下怎么解决这个问题。思路一是我自己的解法,思路很简单,就是通过对每一位依次进行&1运算,如果结果返回1,则当前位也就位1。下面是python代码。def hammingWeight_s1(n): """ :type n: int :rtype: int """原创 2021-09-11 12:08:15 · 206 阅读 · 0 评论 -
二叉树结构的遍历总结以及python实现
前言作为一种经典的非线形数据结构,树的应用十分广泛。在这篇文章中,我会总结一下关于树结构的一个重要问题:遍历。和线形结构不同,树的遍历存在多种方式,最主要的3种就是前序,中序以及后序遍历。当然还有其他方式比如层次遍历等。OK,我们进入正题。前序遍历...原创 2021-07-13 20:57:24 · 316 阅读 · 0 评论