算法练习
文章平均质量分 53
wblong_cs
GIS,CAD ,3D ,BIM
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
多边形边的插值
使用ChatGPT-中文版 VSCode,基本可以写出一个简单的算法,但是正确与否还需要个人Debug及修改,可以节省一部分时间和精力。原创 2023-07-06 21:30:57 · 586 阅读 · 0 评论 -
MultiTree多叉树
MultiTree多叉树的设计、建立、层次优先遍历和深度优先遍历编译运行测试cmake -B build -S .cmake --build build --config Debug.\build\Debug\MultiTree.exe data.txt测试用例层次遍历aA, g, cC, z, bBbB, d, f, i, x, e, j,深度优先遍历aA, g, d, x, e, j, cC, z, f, i, bBbB,其他测试参考多叉树的设计、建立、层次优先遍历和深原创 2021-08-21 17:06:11 · 1121 阅读 · 0 评论 -
拟合仿射变换
Fit an affine transformation to given points给定点拟合仿射变换The following Python function finds, by least squares fitting, an affine transformation that (approximately) transforms given set of points/vertices/vectors (from_pts) to another (to_pts). It works wit原创 2020-10-09 17:26:50 · 870 阅读 · 1 评论 -
实现简单的计算器
拆解复杂问题:实现计算器我们最终要实现的计算器功能如下:输入一个字符串,可以包含+ - * /、数字、括号以及空格,你的算法返回运算结构。要符合运算法则,括号的优先级最高,先乘除后加减。除号是整数除法,无论正负都向 0 取整(5/2=2,-5/2=-2)。可以假定输入的算式一定合法,且计算过程不会出现整型溢出,不会出现除数为 0 的意外情况。比如输入如下字符串,算法会返回 9:3...转载 2020-02-24 18:14:42 · 1184 阅读 · 0 评论 -
二叉树层序遍历
二叉树层序遍历(广度优先遍历)struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};class levelOrderIter {public: vector<vector<int>>...原创 2020-02-21 17:06:25 · 199 阅读 · 0 评论 -
二叉树的前中后序遍历递归与迭代
/** * Definition for a binary tree node. * */struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};class Solution { public: v...原创 2020-02-21 11:19:42 · 220 阅读 · 0 评论 -
Top k问题
最接近原点的 K 个点#include <vector>#include <queue>using namespace std;class Solution { //比较结构体 Functional struct cmp { bool operator()(pair<int, int>&a, pair<int, int>&a...原创 2020-02-20 15:38:41 · 248 阅读 · 0 评论 -
相等的有理数
相等的有理数#include <string>using namespace std;class Solution {public: using ll = long long; // 寻找n, m的最大公约数,辗转相除法 n<m ll gcd(ll n, ll m) { if (n > m) return gcd(m, n); if (n == 0 ...原创 2020-02-20 15:14:13 · 270 阅读 · 0 评论 -
C++ list 与 deque 比较
题目描述:dota2-senate#include <string>#include <list>using namespace std;class Solution {public: string predictPartyVictory(string senate) { int cnt = 0; list<int> R; list<...原创 2020-02-20 11:52:04 · 1760 阅读 · 0 评论 -
C++ STL map和 unordered_map
#include<string>#include<iostream>#include<map>using namespace std;struct person{ string name; int age; person(string name, int age) { this->name = name; this->...原创 2020-02-19 15:59:15 · 235 阅读 · 0 评论 -
删除链表的重复元素
/** * 给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中 没有重复出现 的数字。 * * 示例 1: * 输入: 1->2->3->3->4->4->5 * 输出: 1->2->5 * 示例 2: * 输入: 1->1->1->2->3 * 输出: 2->3 * }; */c...原创 2020-02-19 14:40:18 · 185 阅读 · 0 评论 -
道格拉斯-普克 Douglas-Peuker(DP算法)-python实现
#-*- coding:utf-8 -*-"""道格拉斯算法的实现程序需要安装shapely模块"""import mathfrom shapely import wkt,geometryclass Point: """点类""" x=0.0 y=0.0 index=0 #点在线上的索引 def __init__(self,x,y,index): self.x=x原创 2016-05-02 18:56:23 · 8861 阅读 · 15 评论 -
C++ LRU 不同的实现方式
#include <list>#include <unordered_map>#include <cassert>#include <iostream>using namespace std;class LRUCache { struct Element { int key; int value; Element(int...原创 2020-02-19 11:28:07 · 219 阅读 · 0 评论
分享