果粒陈33
果粒陈33
全部文章
题解
归档
标签
去牛客网
登录
/
注册
果粒陈33的博客
全部文章
/ 题解
(共23篇)
题解 | #求二叉树的前序遍历#
# class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # # # @param root TreeN...
Python2
Python3
2022-06-20
0
400
题解 | #访问单个节点的删除#
# -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Remove: def removeN...
Python2
Python3
2022-06-20
0
484
题解 | #另类加法#
# -*- coding:utf-8 -*- class UnusualAdd: def addAB(self, A, B): # write code here while B: C = A ^ B B = ...
Python2
Python3
2022-06-20
0
423
题解 | #词频统计#
# -*- coding:utf-8 -*- class Frequency: def getFrequency(self, article, n, word): # write code here n = 0 for s in articl...
Python2
Python3
2022-06-20
0
341
题解 | #井字棋#
# -*- coding:utf-8 -*- class Board: def checkWon(self, board): # write code here # 最笨的办法,每种情况都考虑,逐一排查 if board[0][0] + bo...
Python2
Python3
2022-06-19
0
329
题解 | #无缓存交换#
# -*- coding:utf-8 -*- class Exchange: def exchangeAB(self, AB): # write code here # 使用异或性质 AB[0] ^= AB[1] AB[1] ...
Python2
Python3
2022-06-19
0
323
题解 | #最近公共祖先#
# -*- coding:utf-8 -*- class LCA: def getLCA(self, a, b): # write code here # 因为是按顺序排列的满二叉树,所以可以根据性质计算 while a != b: ...
Python2
Python3
2022-06-19
0
351
题解 | #判断直线相交#
# -*- coding:utf-8 -*- class CrossLine: def checkCrossLine(self, s1, s2, y1, y2): # write code here if s1 == s2 and y1 == y2: # 直...
Python2
2022-06-18
0
344
题解 | #碰撞的蚂蚁#
# -*- coding:utf-8 -*- import math class Ants: def antsCollision(self, n): # write code here return 1 - math.pow(0.5, n-1)
Python2
Python3
2022-06-18
0
378
题解 | #整数转化#
# -*- coding:utf-8 -*- class Transform: def calcCost(self, A, B): # write code here temp = A ^ B counter = 0 ...
Python2
2022-06-18
0
319
首页
上一页
1
2
3
下一页
末页