# Algorithm-Learning-LeetCode **Repository Path**: vincentmliu/Algorithm-Learning-LeetCode ## Basic Information - **Project Name**: Algorithm-Learning-LeetCode - **Description**: 每日一道,身轻如燕 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-08-31 - **Last Updated**: 2022-12-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [刷题记录]( https://docs.qq.com/sheet/DY0FtSVNpQ0J6Skxm) ##leetCode 插件模板 ### 文件名: ID$!velocityTool.leftPadZeros(${question.frontendQuestionId},5)$!velocityTool.camelCaseName(${question.titleSlug}) ### 题目模板: ${question.content} package com.xixi.leetcode.editor.cn; public class ID$!velocityTool.leftPadZeros(${question.frontendQuestionId},5)$!velocityTool.camelCaseName( ${question.titleSlug}) { public static void main(String[] args) { Solution solution = new ID$!velocityTool.leftPadZeros(${question.frontendQuestionId},5)$!velocityTool.camelCaseName( ${question.titleSlug})().new Solution(); } ${question.code} } ## 地里打卡模板 2022-07-22打卡 Interview 17.07 婴儿名字 Link:https://leetcode-cn.com/problems/baby-names-lcci/ 题解:https://gitee.com/vincentmliu/Al ... _BabyNamesLcci.java 耗时: 60min 笔记: 1. 通过names初始化并查集元素,names中的名字不一定包含在synonyms中,循环names,时间n 2. 遍历synonyms,合并并查集元素。比较每一组synonym, compareTo 小的就放到value里面,当爹。时间s + logs( find爹,理论上是logs,最差情况是s) 3. 注意!synonyms中的名字不一定包含在names中,所以每个synonym中的名字也要检查是否存在,并且初始化。conner case 4. 遍历names,将所有root的计数合并保存在map中,时间n 5. 遍历map,输出结果,最坏时间n 6. find中可以将非初始化的名字对进行合并 时间复杂度 3*n + s * logs 空间复杂度 需要保存一个,最差s+n的map