首页
题库
公司真题
专项练习
面试题库
在线编程
面试
面试经验
AI 模拟面试
简历
求职
学习
课程
专栏·文章
竞赛
搜索
我要招人
发布职位
发布职位、邀约牛人
更多企业解决方案
在线笔面试、雇主品牌宣传
登录
/
注册
江南201901122252794
获赞
4
粉丝
1
关注
1
看过 TA
0
男
中南大学
2020
算法工程师
IP属地:未知
暂未填写个人简介
私信
关注
拉黑
举报
举报
确定要拉黑江南201901122252794吗?
发布(14)
刷题
江南201901122252794
2019-11-04 16:38
已编辑
算法工程师
Python解法
# -*- coding:utf-8 -*- #2020秋招vivo算法题二题源 class Solution: def LastRemaining_Solution(self, n, m): if n < 1: return -1 arr=list(range(n)) r=-1 l=0 while arr: k=(l+m-1)%n r=arr[k] arr.pop(k) n-=1...
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-04 11:21
已编辑
算法工程师
Python解法:二分
思路参考 drdr # -*- coding:utf-8 -*- from bisect import bisect_left class Solution: def GetNumberOfK(self, data, k): # write code here l=bisect_left(data,k-0.5) r=bisect_left(data,k+0.5) return r-l
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-04 10:19
算法工程师
Python解法:哈希
思路类似字符串第一个出现一次的字符差不多 # -*- coding:utf-8 -*- from collections import Counter#哈希解法 class Solution: # 返回[a,b] 其中ab是出现一次的两个数字 def FindNumsAppearOnce(self, array): # write code here dict=Counter(array) res=[] for i in array: if dict[i]==...
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-04 09:49
已编辑
算法工程师
Python解法:哈希
class Solution: def FirstNotRepeatingChar(self, s): # write code here l=[0]*256 for i in s:#记录每个字符出现的次数 l[ord(i)]+=1 for j,v in enumerate(s):#再按照s的顺序去查看l中次数为1的字符 if l[ord(v)]==1: return j return -1另外也可以借助计数字典实现,代码如下:...
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-03 20:54
算法工程师
Python解法:动态规划
''' dp解法 dp[i]表示到 0-i之间连续最大和 则状态转移方程为: dp[i]=max(array[i],dp[i-1]+array[i]) ''' class Solution: def FindGreatestSumOfSubArray(self, array): # write code here if not array: return 0 n=len(array) if n==1: return array[0] else: ...
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-03 20:43
算法工程师
Python解法:实现快排
#考察排序那就手动实现以下快排 顺便熟悉下O(nlogn) python中的sort()时间复杂度就是O(nlogn) class Solution: def GetLeastNumbers_Solution(self, tinput, k): # write code here def qsort(arr, l, r): if l < r: p = partion(arr, l, r)#找到一个p 使得小于p的位于arr[l]的左侧,大于arr[l]的在p右侧 ...
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-03 20:21
算法工程师
Python解法
# -*- coding:utf-8 -*- class Solution:#不用count() 时间复杂度为O(n) def MoreThanHalfNum_Solution(self, numbers): # write code here if not numbers: return 0 n=len(numbers) num=numbers[0] cnt=1 #如果存在一个数大于一半数组长度的话 for i in range(n): ...
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-02 16:59
算法工程师
python解法Queue容器实现bfs
#熟悉Queue容器的 的 .put() .get() .empty()用法 # -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None import Queue #python2为import Queue / python3中为 import queue class Solution: # 返回从上到下每个节点值列表,例:[1,2,3] d...
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-01 16:36
算法工程师
python四指针法
# -*- coding:utf-8 -*- ''' 思路很简单,直接模拟这个过程采用四个指针来控制遍历 top=0 ── ── → ┐ right=len(matirx[0]) ┌ ── → ┐ | ↑ ↓ | | ↓ left=0 └ ← ── ┘ ...
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-01 11:34
算法工程师
python递归解法
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def HasSubtree(self, pRoot1, pRoot2): # write code here def cmp(p1,p2):#递归比对函数 if not p2:# p2都没有了 说明比较完...
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-01 10:35
已编辑
算法工程师
python 递归解法
# -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None ''' 递归: 1.开始状态 |pHead|--->|pHead.next|--> …… 2.递归:假设pHead.next之后的结点已经反转则如下: ___________________ newHead=self.ReverseList(pHead.next) | ...
0
点赞
评论
收藏
转发
江南201901122252794
2019-11-01 10:02
算法工程师
python解法
#方法一 用list存储访问倒数第k个 注意存储的是ListNode结点 class Solution: def FindKthToTail(self, head, k): # write code here if not head or k<0 : return res=[] while head: res.append(head) head=head.next return res[-k] ...
0
点赞
评论
收藏
转发
江南201901122252794
2019-10-31 10:21
算法工程师
python 解法
这里利用数组的特性一步一步缩小寻找范围:我们取出初始的i=len(array) ,j=0即左下角元素1.如果此时的array[i][j]==target return True2.如果此时的array[i][j]>target 需要缩小寻找方位 i-=1 就可以3.如果此时的array[i][j]<target 需要缩小寻找方位 j+=1 就可以 # -*- coding:utf-8 -*- class Solution: # array 二维列表 def Find(self, target, array): # write code here ...
0
点赞
评论
收藏
转发
江南201901122252794
2019-09-07 14:33
已编辑
算法工程师
迷宫问题 暴力dfs
来个暴力dfs def dfs(i, j, MG, I, J, lujin, temp): if i== I-1 and j ==J-1:#找到出口 递归结束 打印即可 for i in range(len(temp)): print("(%d,%d)"%(temp[i][0],temp[i][1])) return if i + 1 <I and MG[i+1][j]==0:#只往i+1 和j+1两个方向搜索 没有重复路径 dfs(i + 1, j, MG, I, J, lujin, tem...
0
点赞
评论
收藏
转发
1
工具箱
TA的圈子
暂未加入圈子
TA的圈子
TA的笔记
暂无笔记
TA的笔记
登录
0
天
已登录
0
天
连续登录
0
人
今日访客
牛客网
牛客企业服务