Skip to content

Instantly share code, notes, and snippets.

@Fansaly
Fansaly / dfs.py
Last active March 13, 2025 07:14
def dfs(source, each, end):
if not isinstance(source, list) or len(source) == 0:
return [];
# 当前节点所在世界
depth = 0;
# 当前节点父级,以 depth 为索引
parents = [];
# 当前节点坐标,以 depth 为索引
position = [{ 'index': 0, 'total': len(source) }];
@Fansaly
Fansaly / combineMaxValue.js
Created November 9, 2022 02:04
数组 A 中给定可以使用的 1~9 的数,返回由 A 数组中的元素组成的小于 n 的最大数。
/**
* 字节面试题,求大佬们看看,数组 A 中给定可以使用的 1~9 的数,返回由 A 数组中的元素组成的小于 n 的最大数。
* 例如 A = {1, 2, 4, 9},x = 2533,返回 2499
* 兄弟们这个题怎么做呀,或者给一下有没有力扣类似的题的链接
*
* 作者:Damon
* 链接:https://leetcode.cn/circle/discuss/fbhhev/
*/
const findNumbers = (array, target) => {
@Fansaly
Fansaly / tree.js
Last active February 17, 2023 10:07
generate tree(s)
/**
* 现有一些杂乱的数据,我们想整理一下,让
* 它看起来稍微舒服直观一点。
* --------------------------------
* 1. 每个子节点仅有一个父节点
* 2. 可能存在多个根节点
* 3. 根节点是未知的
* --------------------------------
* 元数据如下,请根据 id 与 pid 的关系,
* 将数据改造为树型结构。
const data0 = [
[
{ id: 1126869436, name: '1' },
],
]
const data1 = [
[
{ id: 1126869436, name: '1' },
{ id: 1126869437, name: '2' },
],
  小新 潮7000 14 小新 Air 15 说明
地址 京东 | 联想 京东 | 联想  
价格 5599 5599 请关注价格波动
颜色 极光银 轻奢灰 由喜好而定
CPU i7-8550U i5-8265U 共同 4 核心 8 线程
前者 8M 缓存
后者 6M 缓存 [详细对比]
建议 对于新人使用体验来说应无明显差异
GPU AMD Radeon 535 NVIDIA GeForce MX150 共同 独显,2G 显存
建议 对于新人使用体验来说应无明显差异
内存 8G 8G  
硬盘 128G SSD
1T HDD
512G SSD 共同 都有“恢复系统”,占用空间或许 40±G
前者 SSD 用来安装系统和应用,HDD 用来储存数据
后者 实际可用容量或许只有 460G(500-40),系统、应用分配 100G,可使用 360G 来储存数据
建议 请根据需求而定
输入设备 键盘、触摸板 键盘、触摸板、指纹 后者 ① 键盘背光(关、暗、亮) &
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
import getopt
def help():
print '''
-i, --input Input file.
-o, --output Output file.
@Fansaly
Fansaly / combineArray.js
Last active March 10, 2018 20:45
返回数组中所有的元素的组合数组
/**
* 写一个函数,传入一个数组,
* 要求返回数组中所有的元素组合的数组
*
* [1, 2] => [
* 12,
* 21,
* ]
* [1, 2, 3] => [
* 123, 132,
@Fansaly
Fansaly / getMinValue.js
Last active October 10, 2017 09:12
一个先递减后递增,并且最小值只有一个的数组,获取其最小值及位置
/**
* 已知一个数组,满足如下几个条件:
* --------------------------
* 存储的都是整数
* 数组数据量大
* 数组数值先递减,再递增(例如 [9, 8, 7, 6, 5, 6, 9 , 11])
* 数组内最小值只有一个
* ----------------------------------------------------------
* 请编程获取到这个数组内的最小值(请自行实现算法,不要使用系统自带函数)
* --------------------------------
@Fansaly
Fansaly / certonly-nginx.ini
Last active March 9, 2018 02:29
Certbot's config files
# This is an example of the kind of things you can do in a configuration file.
# All flags used by the client can be configured here. Run Certbot with
# "--help" to learn more about the available options.
# use certbot certonly --config (or -c) configuration file.
# register with the specified e-mail address
email = name@example.com
# generate certificates for the specified domains.
# enter a comma separated list of domains as a parameter.