算法
andeyeluguo
这个作者很懒,什么都没留下…
展开
-
bfs基本算法
一个queue只要不空。不断地push 和pop #include <queue> using namespace std; struct Tree { Tree *left; Tree *right; }; void bfs(Tree *root) { queue<Tree *> que; que.push(root); while (!que.empty()) { que.push(root->left)原创 2021-08-26 09:11:49 · 77 阅读 · 0 评论 -
旋转数组
将两个数组进行旋转 /* * @lc app=leetcode.cn id=345 lang=cpp * * [345] 反转字符串中的元音字母 */ // @lc code=start class Solution { public: string reverseVowels(string s) { vector<int> ret; for (int i = 0; i < s.size(); i++) { if原创 2020-11-19 19:24:46 · 73 阅读 · 0 评论 -
算法与化归思想
可以采用化归的方法解东西,如生命游戏,如果讨论,则要讨论四个角落和边几个情况,可以通过补pad,将边上的特殊情况化归为一般情况。 int computer(int num, int a) { int b = a; if (a == 1) { if (num < 2) { b = 0; } else if (num == 2 || num == 3) { b = 1; } else {原创 2020-11-04 21:30:30 · 97 阅读 · 0 评论 -
算法与记忆
使用数形结合的思想记忆一些经典的的算法,然后修改使用 /* * @lc app=leetcode.cn id=4 lang=cpp * * [4] 寻找两个正序数组的中位数 */ // @lc code=start class Solution { public: double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) { for (int i =原创 2020-11-04 19:49:39 · 134 阅读 · 0 评论 -
动态规划
动态规划问题: /* * @lc app=leetcode.cn id=63 lang=cpp * * [63] 不同路径 II */ // @lc code=start class Solution { public: int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) { int m = obstacleGrid.size(); int n =原创 2020-11-02 17:32:32 · 61 阅读 · 0 评论 -
查找算法
面试的时候一般也会考察二分查找算法,在数组中查找 指定的元素。二分查找排序的是有序的数组。 折半查找为总数为奇数时,取中间的,总数为偶数时,取中间右边的。 // keshan.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include //时间复杂度 //顺序查找 int seq_search(int a[],int n,int key){原创 2017-03-08 16:34:53 · 217 阅读 · 0 评论 -
算法时间复杂度
算法时间复杂度大概是某个主要步骤重复的次数,而不是时间。 比如冒泡算法的时间复杂度为o(n^2)原创 2017-03-07 11:24:17 · 439 阅读 · 0 评论 -
排序算法
通常面试的时候先让你来个冒泡算法,背下来就行吧// keshan.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" void bubble_sort(int a[],int n){ int i,j,tmp; for(j = 0;j<n-1;j++){ for(int i=0;i<n-1-j;i++){ if(a[i]<a[i+1]){原创 2017-03-07 11:08:52 · 530 阅读 · 3 评论 -
算法工程师的一些认识
1.算法工程师不是用机器学习包进行工程创建的人员,那是应用工程师,算法工程师应该懂得算法设计、算法的数学原理、实现步骤并能进行算法实现。 2.talk is cheap,show me your code.代码,代码,不断地编写代码。 3.思考,思考,再思考。对每句话都先复制到自己脑子里,然后撇开材料。对立进行创造。 4.算法工程师对数学要求并不是非常高,但对理解能力要求高,空间想象能力,能...原创 2017-03-22 09:47:42 · 1180 阅读 · 0 评论