blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9ebc746a4620237c3ed99208995f54a685602e07
siddharth-sen/Data-Structures
/priority_queues_and_disjoint_sets/build_heap.py
2,102
3.75
4
# python3 # def build_heap_naive(data): # """Build a heap from ``data`` inplace. # # Returns a sequence of swaps performed by the algorithm. # """ # # The following naive implementation just sorts the given sequence # # using selection sort algorithm and saves the resulting sequence # # of swa...
4f87d09bb2e1b7672abbb04b858744c395c56a4a
omdeshmukh20/Python-3-Programming
/Max_min.py
786
3.8125
4
#Discription: Accept Digit From User And Find Maximum & Minimum Digit & Find Difference #Date: 14/08/21 #Author : Om Deshmukh # Max_Min Operation def Max_Min(iValue1): iMax = 0 iMin = 9 iDigit = 0 if iValue1 <= 0: exit("Invalid Input! | Note : Give Input Greater Than 0") while iValue1 ...
4d93350b900eca09bc409262185344f043ab0bda
omdeshmukh20/Python-3-Programming
/Expectation2.py
494
3.875
4
# Python Program To Handle The ZeroDivisionError Exception #Discription: Python Program To Handle The ZeroDivisionError Exception #Date: 22/08/21 #Author : Om Deshmukh try: f = open("myfile", "w") a, b = [int(x) for x in input("Enter Two Numbers : ").split()] c = a/b f.write("Writing %d Into myf...
3c3076cd3c7f1f4bfac557c75468ca4697aa3267
omdeshmukh20/Python-3-Programming
/Dict2.py
363
3.5625
4
#Discription: Program for finding name of batch from directory.. #Date: 26/06/21 #Author : Om Deshmukh def main(): batches = {"PPA":12500, "LB":11000, "Python":13000, "Angular" : 10000, "LSP":11000} print("Enter the batch name") name = input() print(batches.get(name,"There is no such batch"))...
925c30658ecf796029144d60a849e02ac8ad5c3b
omdeshmukh20/Python-3-Programming
/Arithmetic6.py
568
4.09375
4
#Discription: Multiplication of two numbers using function #input: From user #output: Expected to user #Date: 10/06/21 #Author : Om Deshmukh def Multiplication(value1, value2): ret=value1*value2 return ret def main(): no1=int(input("Enter first number")) no2=int(input("Enter second number")) a...
ce9e491b8ccf18f19fc324f45f4ba1bf44f4bcf0
omdeshmukh20/Python-3-Programming
/Demo.py
333
3.65625
4
#Discription: Creating a file #Date: 24/06/21 #Author : Om Deshmukh def main(): name = input("Enter the file name that you want to create") fobj = open(name,"w") # create new file str = input("Enter the data that you want to write in the file") fobj.write(str) if __name__ == "__ma...
b3a355ee7c9dc63b6fbcad65157bd76cc3a1e427
omdeshmukh20/Python-3-Programming
/AreaCircle.py
337
4.125
4
#Function Name:AreaCircle.. #Input: 5.. #Output:Area of Circle is 78.53981633974483 # Area of Circle is 78.54 #Description:Calculates Area of Circle #Date: 10/07/2021 #Author: Shubham Lodha import math r=float(input("Enter Radius")) ans=float(math.pi*r*r) print("Area of Circle is",ans); print("Area of Circle i...
c657cf3dabe51689851aec919b4cae2fa88a388b
omdeshmukh20/Python-3-Programming
/I E1.py
242
3.578125
4
#Discription: If else #Date: 08/07/21 #Author : Om Deshmukh def main(): print("Enter the num:") num=int(input()) if num<10: print("Hello") else: print("Demo") if __name__ == '__main__': main()
ccd42f45d362c002952ff12c12dd7196ea26c9bb
omdeshmukh20/Python-3-Programming
/PZN.py
277
3.828125
4
#Discription: Positive, zero or negative number #Date: 1/07/21 #Author : Om Deshmukh def checknum(Number): if Number>0: print("The number is positive") elif Number==0: print("The number is zero") else: print("The number is negative") checknum(11) checknum(-8) checknum(0)
807408f358eb6169b8ccc29b31fb9915b3cb422f
omdeshmukh20/Python-3-Programming
/Lambda5.py
452
3.96875
4
#Discription: Accept N Numbers From User And Multiply The Number Using Lambda Function #Date: 30/08/21 #Author : Om Deshmukh def main(): Mult = lambda iNo1, iNo2 : iNo1 * iNo2 value1 = int(input("Enter First Number For Multiply : ")) value2 = int(input("Enter Second Number For Multiply : ")) ret =...
23dd3e9810bbf1e4958d0cadb646c0240be0dad7
omdeshmukh20/Python-3-Programming
/string2.py
229
3.828125
4
#Discription: Check string. #Date: 15/07/21 #Author:Om Deshmukh main=input("Enter a Main String:") sub=input("Enter a SubString:") if sub in main: print(sub+"is Found is Main String") else: print(sub+"is Not Found in Main String")
4411ee7600d12fefc86504b5b9a1f2027f0d81cf
omdeshmukh20/Python-3-Programming
/prime.py
242
3.75
4
#Discription : No is prime or not #Date: 4/07/21 #Author : Om Deshmukh num=5 conditon=False if num>1: for i in range(2,num): if num%i==0: conditon=True if conditon: print(num,"is not a prime number") else: print(num,"is a prime number")
c07ab241fcb59a8ee02581ae57aed3f7e5fc5e05
omdeshmukh20/Python-3-Programming
/Character.py
196
3.609375
4
##Discription: Entering the character.. #Date: 09/08/21 #Author : Om Deshmukh def main(): ch=input("Enter the character:") print("The entered char is=",ch[1]) if __name__ == '__main__': main()
4183c587dc44a96add3a66462ec2304e8b7168dc
omdeshmukh20/Python-3-Programming
/Selection2.py
395
3.671875
4
#Discription : Demonstration of selection by function. #Date: 15/06/21 #Author : Om Deshmukh def CheckEven(No): if No%2==0: return True else: return False def main(): print("enter one number") value=int(input()) bret=checkEven(value) if bret==True: print("{} is Even Number".format(value)) else: ...
1963c9e0a6dba5e722c51aa57cef1ebd0c49080e
omdeshmukh20/Python-3-Programming
/practice2.py
297
3.6875
4
#Discription: Factorial #Date: 28/06/21 #Author : Om Deshmukh def print_factors(x): print("The factors of",x,"are:") for i in range(1, x + 1): if x % 1 == 0: if x % 2 == 0: print(i) number = 24 def main(): print_factors(number) if __name__ == '__main__': main()
4b2ea5946e0af1d89405ac27211b04b97ceb7839
omdeshmukh20/Python-3-Programming
/Recurssion7.py
425
3.953125
4
#Discription : Accept N Number From User And Find The Factorial Using Recursion #Date: 2/09/21 #Author : Om Deshmukh def Recursion_Factorial(iNo): if(iNo == 0): return 1 return iNo * Recursion_Factorial(iNo - 1) def main(): value = int(input("Enter The Number : ")) iRet = Recursion_Factoria...
b3706b107ba61d4b4b54974ff94b64b50ba2f136
omdeshmukh20/Python-3-Programming
/OOP5.py
729
4
4
#Discription: Base 1,2 constructor and Derived constructor #Date: 18/06/21 #Author : Om Deshmukh class Base1: def __init__(self): self.i = 10 self.j = 20 print("Inside Base1 constructior") class Base2: def __init__(self): self.x = 10 self.y = 20 print("Inside Bas...
22b1e72114828dbc547f169eb1954ee9b59a732f
omdeshmukh20/Python-3-Programming
/Array.py
348
3.671875
4
#Discription: Type , Range , length of an array #Date: 26/06/21 #Author : Om Deshmukh from array import* def main(): arr=array('i',[11,1,51,101,111,121]) print(type(arr)) print(len(arr)) print(arr[0]) for i in range(len(arr)): print(arr[i]) icnt=0 while icnt<len(arr): print(arr[icnt]) icnt+=icnt+1 ...
71669ad96d6258fdb0a7885e097d334a0b40f751
omdeshmukh20/Python-3-Programming
/forloop.py
495
4.0625
4
#Discription: Using for loop #Date: 14/06/21 #Author : Om Deshmukh def DisplayF(value): print("Output of for loop") icnt = 0 for icnt in range(0,value): print("Jay Ganesh") def DisplayW(value): print("Output of while loop") icnt = 0 while icnt < value: print("Jay Ganesh") ...
181490c8b16220852a50ddb72ae7b2c7a19f77cf
omdeshmukh20/Python-3-Programming
/class3.py
626
4.375
4
#Discription:# Python Program To Create A Static Method That Counts The Number Of Instances Created For A Class #Date: 19/08/21 #Author : Om Deshmukh class Myclass: # This Is Class Variable Or Static Variable n = 0 # Constructor That Increments n When An Instance Is Created def __in...
7a84b91bd316de0a7c8339f8698e880be2a26764
omdeshmukh20/Python-3-Programming
/OOP8.py
611
3.78125
4
#Discription:Recursive call #Date: 19/06/21 #Author : Om Deshmukh class Base: def __init__(self): self.i = 10 self.j = 20 def fun(self): print("Base fun") class Derived(Base): def __init__(self): Base.__init__(self) #self.__init__() Recursive call ...
e2ce92b8103ef2550e7e83447ea9b5388253e7bd
omdeshmukh20/Python-3-Programming
/Append.py
293
3.890625
4
#Discription: Printing max num from arr #Date: 27/07/21 #Author : Om Deshmukh def main(): arr=[] size=int(input("Enter the size of array")) for i in range(size): arr.append(int(input())) print("Data is : ",arr) print("Maximum number is : ",max(arr)) if __name__ == '__main__': main()
d0eabf0d5cc5c7596315441454ad10192ff331f5
omdeshmukh20/Python-3-Programming
/class4.py
411
4.21875
4
#Discription:Static Method To Find Square Root Value #Date: 19/08/21 #Author : Om Deshmukh import math class Sample: @staticmethod def calculate(x): result = math.sqrt(x) return result # Accept A Number From Keyboard num = float(input('Enter A Number : ')) # Call The Static Method And ...
0972f03223726514be509f4a6e97f45eab48da5e
ddanielkwan/problems
/counting_a.py
169
3.6875
4
s = 'abc' n = 100 default = s.count('a') extra_len = n % len(s) extra_count = s[:extra_len].count('a') print(f' This many a\'s: {default * (n//len(s)) + extra_count}')
77c943744f699f0006c272ecb908bafcb8ef8931
kferr0012/CS170_AI_Project1
/project_1_src/misplaced_tile_h.py
1,426
3.578125
4
from tree_and_node_class import * from operations import * import copy def assign_h_with_misplaced_tile(given_node,goal_state): #return value h_value=0 do_bs_match=False #Grab current State node_state = copy.deepcopy(given_node.current_state) ideal_state = copy.deepcopy(goal_state) #Fin...
2d0f6b83c8fe47251d8016b22797ac78cf409065
Katherinaxxx/leetcode
/54. 螺旋矩阵Spiral Matrix.py
1,025
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/8/24 下午10:41 @Author : Catherinexxx @Site : @File : 54. 螺旋矩阵Spiral Matrix.py @Software: PyCharm """ # 遍历 + 取余数调整遍历方向 time O(n) class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: if not matrix: return [] ...
33fdada4ea9b92681e848721aa168042832b6b7a
Katherinaxxx/leetcode
/43. 字符串相乘Multiply Strings.py
899
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/8/24 下午11:27 @Author : Catherinexxx @Site : @File : 43. 字符串相乘Multiply Strings.py @Software: PyCharm """ class Solution: def multiply(self, num1: str, num2: str) -> str: return str(int(num1)*int(num2)) class Solution: def multiply(self, num...
41ef852d0cbcd89fab4477470cd9a1a6f7e2da0f
Katherinaxxx/leetcode
/Add Two Numbers.py
885
3.90625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/4/23 下午10:08 @Author : Catherinexxx @Site : @File : Add Two Numbers.py @Software: PyCharm """ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def a...
46ed182dfebb2f28e431f435357144a3a8a3931c
Katherinaxxx/leetcode
/617. Merge Two Binary Trees.py
1,537
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/4/23 下午8:43 @Author : Catherinexxx @Site : @File : 617. Merge Two Binary Trees.py @Software: PyCharm """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.r...
cf3fd7d6d3dfab837dba524bd1c1e9ab213d45ed
Katherinaxxx/leetcode
/502. IPO.py
2,154
3.5625
4
''' Author: Catherine Xiong Date: 2021-09-08 19:16:27 LastEditTime: 2021-09-08 19:33:26 LastEditors: Catherine Xiong Description: 给你 n 个项目。对于每个项目 i ,它都有一个纯利润 profits[i] ,和启动该项目需要的最小资本 capital[i] 。 最初,你的资本为 w 。当你完成一个项目时,你将获得纯利润,且利润将被添加到你的总资本中。 总而言之,从给定项目中选择 最多 k 个不同项目的列表,以 最大化最终资本 ,并输出最终可获得的最多资本。 来源:力扣(LeetCode) 链接:h...
24234929366414f5253ba242da97161dcddd10a7
Katherinaxxx/leetcode
/22.generate-parentheses.py
1,855
3.84375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2019/10/24 下午6:57 @Author : Catherinexxx @Site : @File : 22.generate-parentheses.py @Software: PyCharm """ # 1、递归所有可能组合 再加条件筛选即可递归出合法组合 优 class Solution: def generateParenthesis(self, n): res = [] def generate(left, right, s): i...
88726807c3fd1d843b6ea281f69aa886596ada6f
Katherinaxxx/leetcode
/1137. 第 N 个泰波那契数.py
789
3.828125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2021/8/8 8:43 PM @Author : Catherinexxx @File : 1137. 第 N 个泰波那契数.py @Description: 泰波那契序列 Tn 定义如下:  T0 = 0, T1 = 1, T2 = 1, 且在 n >= 0 的条件下 Tn+3 = Tn + Tn+1 + Tn+2 给你整数 n,请返回第 n 个泰波那契数 Tn 的值。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/n-th-tribonacci-n...
66fdba61987ced5d7c81decd8787ef13a9663034
Katherinaxxx/leetcode
/LCOF9用两个栈实现队列.py
1,212
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/2/20 下午1:23 @Author : Catherinexxx @Site : @File : LCOF9用两个栈实现队列.py @Software: PyCharm """ """ https://www.cnblogs.com/eniac12/p/4865158.html """ # # 一个栈 # class CQueue: # def __init__(self): # self.queue = [] # self.head = None # ...
9c1391d4fa2e67525eee115fe57708edf926c70a
Katherinaxxx/leetcode
/387. First Unique Character in a String.py
1,280
3.890625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/6/16 上午6:20 @Author : Catherinexxx @Site : @File : 387. First Unique Character in a String.py @Software: PyCharm """ """ 给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 """ # hash存 查找 O(n)time O(n)space class Solution(object): def firstUniqChar(self, s: s...
5510f954c148422ed65eaab406dbfd3ea91e20bd
Katherinaxxx/leetcode
/287. Find the Duplicate Number.py
2,887
3.984375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/5/8 下午1:49 @Author : Catherinexxx @Site : @File : 287. Find the Duplicate Number.py @Software: PyCharm """ """ 给定一个包含 n + 1 个整数的数组 nums,其数字都在 1 到 n 之间(包括 1 和 n),可知至少存在一个重复的整数。假设只有一个重复的整数,找出这个重复的数。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/find-t...
7a3f2350480e7469659609f14bcd3d7869c17173
Katherinaxxx/leetcode
/347. Top K Frequent Elements.py
884
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/5/11 下午8:39 @Author : Catherinexxx @Site : @File : 347. Top K Frequent Elements.py @Software: PyCharm """ # # 库函数 # from collections import Counter # class Solution: # def topKFrequent(self, nums: List[int], k: int) -> List[int]: # return [i[0]...
b5e769a58360ed336e54e94aa254bc23b552e048
Katherinaxxx/leetcode
/122. Best Time to Buy and Sell Stock II.py
488
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2019/10/29 下午2:15 @Author : Catherinexxx @Site : @File : 122. Best Time to Buy and Sell Stock II.py @Software: PyCharm """ # 贪心算法 class Solution: def maxProfit(self, prices: List[int]) -> int: res, i , j = 0, 0, 1 while i < len(prices) and ...
6495a5fed0490787e914c98e5c44bd3395cb79b7
Katherinaxxx/leetcode
/1122. 数组的相对排序.py
1,464
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/11/14 7:52 PM @Author : Catherinexxx @Site : github.com/Katherinaxxx @File : 1122. 数组的相对排序.py @Description: 给你两个数组,arr1 和 arr2, arr2 中的元素各不相同 arr2 中的每个元素都出现在 arr1 中 对 arr1 中的元素进行排序,使 arr1 中项的相对顺序和 arr2 中的相对顺序相同。 未在 arr2 中出现过的元素需要按照升序放在 arr1 的末尾。 来源:力扣(Lee...
03706cd8a132c284bbb44ec95756420a2c94847e
Katherinaxxx/leetcode
/爱奇艺2020秋招.py
1,011
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/8/23 下午2:58 @Author : Catherinexxx @Site : @File : 爱奇艺2020秋招.py @Software: PyCharm """ # 分词结果修改 ori = input().split(' ') target = input().split(' ') i, j, l = 0, 0, 0 for x in ori: l += len(x) res = [] while i < l and j < len(target): if ori[i] no...
60a0fd1027a8e9fd5fbfcc499c34fd627ca8d7ab
Katherinaxxx/leetcode
/剑指 Offer 59 - II. 队列的最大值.py
1,254
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2021/5/22 5:49 PM @Author : Catherinexxx @Site : github.com/Katherinaxxx @File : 剑指 Offer 59 - II. 队列的最大值.py @Description: 请定义一个队列并实现函数 max_value 得到队列里的最大值,要求函数max_value、push_back 和 pop_front 的均摊时间复杂度都是O(1)。 若队列为空,pop_front 和 max_value 需要返回 -1 来源:力扣(LeetCode) ...
097cec78df7397c85ead371b7f7074dfc44ac5a2
Katherinaxxx/leetcode
/700. 二叉搜索树中的搜索.py
1,161
3.71875
4
''' Author: Catherine Xiong Date: 2021-11-29 19:37:11 LastEditTime: 2021-11-29 19:37:12 LastEditors: Catherine Xiong Description: 给定二叉搜索树(BST)的根节点和一个值。 你需要在BST中找到节点值等于给定值的节点。 返回以该节点为根的子树。 如果节点不存在,则返回 NULL。 ''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None):...
eb0f9b33a7b48bf291b9779429d5040760bcc9e7
Katherinaxxx/leetcode
/98. Validate Binary Search Tree.py
1,416
3.859375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/5/5 下午5:11 @Author : Catherinexxx @Site : @File : 98. Validate Binary Search Tree.py @Software: PyCharm """ ''' 给定一个二叉树,判断其是否是一个有效的二叉搜索树。 假设一个二叉搜索树具有如下特征: 节点的左子树只包含小于当前节点的数。 节点的右子树只包含大于当前节点的数。 所有左子树和右子树自身必须也是二叉搜索树。 来源:力扣(LeetCode) 链接:https://leetcode-cn...
4d1a014ffdf3fc5012802802d5624f5e29be611f
Katherinaxxx/leetcode
/13. Roman to Integer.py
2,031
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/6/16 下午3:59 @Author : Catherinexxx @Site : @File : 13. Roman to Integer.py @Software: PyCharm """ """ 给定一个罗马数字,将其转换成整数。输入确保在 1 到 3999 的范围内。 """ # 暴力 有6个小的在左边的例子 超时 class Solution: def romanToInt(self, s: str) -> int: n, i = len(s), 0 re...
069f9bf527ab675e0b60f2c188b94afa905efe1d
Katherinaxxx/leetcode
/19. Remove Nth Node From End of List.py
2,749
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/5/20 下午6:37 @Author : Catherinexxx @Site : @File : 19. Remove Nth Node From End of List.py @Software: PyCharm """ """ 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。 """ # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self....
ed27ddd62c3f9e94b3e3d72471b16348c5f08cfe
Katherinaxxx/leetcode
/53. Maximum Subarray.py
1,577
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2019/11/13 上午11:23 @Author : Catherinexxx @Site : @File : 53. Maximum Subarray.py @Software: PyCharm """ # dp 超时 # class Solution: # def maxSubArray(self, nums: List[int]) -> int: # res = max(nums) # dp = nums # for i in range(1, len...
c42799bd9c8562817da602ce23c2654b6e174dd0
Katherinaxxx/leetcode
/384. 打乱数组.py
1,078
3.6875
4
''' Author: Catherine Xiong Date: 2021-11-22 21:12:47 LastEditTime: 2021-11-22 21:12:48 LastEditors: Catherine Xiong Description: 给你一个整数数组 nums ,设计算法来打乱一个没有重复元素的数组。 实现 Solution class: Solution(int[] nums) 使用整数数组 nums 初始化对象 int[] reset() 重设数组到它的初始状态并返回 int[] shuffle() 返回数组随机打乱后的结果 来源:力扣(LeetCode) 链接:https://leetcode-...
38c0c40467b7d51815ffd6a3cb40287b70a68f60
Katherinaxxx/leetcode
/剑指 Offer 36. 二叉搜索树与双向链表.py
936
3.609375
4
''' Author: Catherine Xiong Date: 2021-11-16 22:31:21 LastEditTime: 2021-11-16 22:31:21 LastEditors: Catherine Xiong Description: 输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的循环双向链表。要求不能创建任何新的节点,只能调整树中节点指针的指向。 ''' """ # Definition for a Node. class Node: def __init__(self, val, left=None, right=None): self.val = val se...
ebb85c5dd43474eddf10599198bca1644b34cd00
Katherinaxxx/leetcode
/746. Min Cost Climbing Stairs.py
1,862
3.828125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/5/24 下午12:33 @Author : Catherinexxx @Site : @File : 746. Min Cost Climbing Stairs.py @Software: PyCharm """ """ 数组的每个索引做为一个阶梯,第 i个阶梯对应着一个非负数的体力花费值 cost[i](索引从0开始)。 每当你爬上一个阶梯你都要花费对应的体力花费值,然后你可以选择继续爬一个阶梯或者爬两个阶梯。 您需要找到达到楼层顶部的最低花费。在开始时,你可以选择从索引为 0 或 1 的元素作为初...
51a19d92d80a11e670e9ea4d25057a3226407346
Katherinaxxx/leetcode
/611. 有效三角形的个数.py
922
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2021/8/4 10:55 PM @Author : Catherinexxx @File : 611. 有效三角形的个数.py @Description: 给定一个包含非负整数的数组,你的任务是统计其中可以组成三角形三条边的三元组个数。 """ # 排序+双指针 # 两边之和大于第三边->只要最长的边小于另外两边之和 则是个有效的三角形 class Solution: def triangleNumber(self, nums: List[int]) -> int: nums.sort() ...
ec3a7aa07184b396499a1caeca5a55983508be1b
Katherinaxxx/leetcode
/326. 3的幂.py
897
4.09375
4
''' Author: Catherine Xiong Date: 2021-09-23 22:02:15 LastEditTime: 2021-09-23 22:03:51 LastEditors: Catherine Xiong Description: 给定一个整数,写一个函数来判断它是否是 3 的幂次方。如果是,返回 true ;否则,返回 false 。 整数 n 是 3 的幂次方需满足:存在整数 x 使得 n == 3x 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/power-of-three 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出...
625384c0dd5849619c872f8437773be863ec13de
Katherinaxxx/leetcode
/剑指 Offer 32 - II. 从上到下打印二叉树 II.py
1,332
3.765625
4
''' Author: Catherine Xiong Date: 2021-07-26 22:45:31 LastEditTime: 2021-09-28 00:04:20 LastEditors: Catherine Xiong Description: ''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # O(n) time O(n) space...
b0ddc9dd569516f5d817b17c4b6ba308cb18dd24
Katherinaxxx/leetcode
/338. Counting Bits.py
1,032
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/4/30 下午5:04 @Author : Catherinexxx @Site : @File : 338. Counting Bits.py @Software: PyCharm """ ''' 给定一个非负整数 num。 对于 0 ≤ i ≤ num 范围中的每个数字 i ,计算其二进制数中的 1 的数目并将它们作为数组返回。 ''' # 库函数 O(n*sizeof(integer)) time class Solution: def countBits(self, num: int) -...
933ae96b2ab01d79cbe3bae7f40fb0bd14e55921
jaisun2004/TamilSpellChecker
/TamilwordChecker.py
626
3.609375
4
import os import traceback from bloomfilter import BloomFilter class TamilwordChecker: def __init__(self,unique_word_count, bloomfilter_file_path): falsepositive_probability = 0.001 self.bloom_tamil = BloomFilter(unique_word_count,falsepositive_probability,bloomfilter_file_path) def tamil_wor...
cd2f3e034cae0e55d728c930583f9be9487781ea
95ktsmith/holbertonschool-machine_learning
/math/0x04-convolutions_and_pooling/3-convolve_grayscale.py
2,132
4.0625
4
#!/usr/bin/env python3 """ Convolve with stride """ import numpy as np def convolve_grayscale(images, kernel, padding='same', stride=(1, 1)): """ Performs a convolution on grayscale images images is a numpy.ndarray with shape (m, h, w) containing multiple grayscale images m is the number o...
4473cfd5268aee85f7ff9caf033560a75c0d0d11
95ktsmith/holbertonschool-machine_learning
/math/0x04-convolutions_and_pooling/1-convolve_grayscale_same.py
1,171
3.78125
4
#!/usr/bin/env python3 """ Same convolution """ import numpy as np def convolve_grayscale_same(images, kernel): """ Performs a same convolution on grayscale images images is a numpy.ndarray with shape (m, h, w) containing multiple grayscale images m is the number of images h is the...
0feab0f8687b7baf3357fc9b7b89997a1e35ad2f
95ktsmith/holbertonschool-machine_learning
/supervised_learning/0x07-cnn/2-conv_backward.py
2,902
4.25
4
#!/usr/bin/env python3 """ Convolution back propagation """ import numpy as np def conv_backward(dZ, A_prev, W, b, padding="same", stride=(1, 1)): """ Performs back propagation over a convolutional layer of a neural network dZ is a numpy.ndarray of shape (m, h_new, w_new, c_new) containing the par...
cb0541668e2fd886a98d18801b4462d8ec700765
95ktsmith/holbertonschool-machine_learning
/unsupervised_learning/0x01-clustering/0-initialize.py
787
3.875
4
#!/usr/bin/env python3 """ Initialize K-means """ import numpy as np def initialize(X, k): """ Inializes cluster centroids for K-means X is a numpy.ndarray of shape (n, d) containing the data set n is the number of data points d is the number of dimensions for each data point k is a po...
771bec821af71de8b3a333b582138fc3b8a80147
95ktsmith/holbertonschool-machine_learning
/math/0x00-linear_algebra/3-flip_me_over.py
307
4.0625
4
#!/usr/bin/env python3 """ Transpose """ def matrix_transpose(matrix): """ Return a transposed version of a 2D matrix """ new_matrix = [[] for i in range(0, len(matrix[0]))] for row in matrix: for i in range(0, len(row)): new_matrix[i].append(row[i]) return new_matrix
0f6be978d017313530bc677f274e310282aeb306
95ktsmith/holbertonschool-machine_learning
/unsupervised_learning/0x02-hmm/3-forward.py
838
3.640625
4
#!/usr/bin/env python3 """ Forward Algorithm """ import numpy as np def forward(Observation, Emission, Transition, Initial): """ Performs forward algorithm for a hidden markov model """ if type(Observation) is not np.ndarray or Observation.ndim != 1: return None, None if type(Emission) is ...
5f16242ee35f7d094d83dc59daeae52a537bdb78
95ktsmith/holbertonschool-machine_learning
/supervised_learning/0x01-classification/3-neuron.py
1,685
3.96875
4
#!/usr/bin/env python3 """ Neuron """ import numpy as np class Neuron: """ Class to represent a neuron performing binary classification """ def __init__(self, nx): """ nx is the number of input features to the neuron """ if type(nx) is not int: raise TypeError("nx must be an intege...
37e1050cde375267ac82a1fcf0851c77ef09ec75
95ktsmith/holbertonschool-machine_learning
/math/0x05-advanced_linear_algebra/1-minor.py
2,022
4.25
4
#!/usr/bin/env python3 """ Matrix of Minors """ def determinant(matrix): """ Calculates the determinant of a matrix matrix must be a square list of lists Returns the determinant of the matrix """ if type(matrix) is not list or len(matrix) == 0: raise TypeError("matrix must be a list of...
6bb5ebc6333efefceb9d3d49de4fef58f03609c9
95ktsmith/holbertonschool-machine_learning
/supervised_learning/0x01-classification/24-one_hot_encode.py
539
3.71875
4
#!/usr/bin/env python3 """ One Hot Encode """ import numpy as np def one_hot_encode(Y, classes): """ Converts a numeric label vector into a one-hot matrix Y is a numpy.ndarray with shape (m,) containing numeric class labels classes is the maximum number of classes found in Y """ if classes...
25544a1078bb3f40be615c0429507fd392cc641c
95ktsmith/holbertonschool-machine_learning
/supervised_learning/0x07-cnn/4-lenet5.py
3,079
3.859375
4
#!/usr/bin/env python3 """ LeNet-5 in Tensorflow """ import tensorflow as tf def lenet5(x, y): """ Builds a modified version of the LeNet-5 architecture using tensorflow x is a tf.placeholder of shape (m, 28, 28, 1) containing the input images for the network m is the number of images y is...
93138a525020edc330c7089460e943833e09d482
95ktsmith/holbertonschool-machine_learning
/pipeline/0x00-pandas/2-from_file.py
340
4.125
4
#!/usr/bin/env python3 """ Load from file """ import pandas as pd def from_file(filename, delimiter): """ Loads data from a file as a pd.DataFrame filename: the file to load from delimiter: the column separator Returns: the loaded pd.DataFrame """ df = pd.read_csv(filename, delimiter=delim...
5ac93cc2399b6210bc469dd5b4810e1863970575
mat105/enviame-backend-test
/Ejercicio-6/estimar.py
697
3.984375
4
import random # Guardar el resultado de calculos previos para evitar recursiones muy grandes a medida que voy creciendo. memo = [0, 1, 1] # Fibonacci pero con la primer posicion siendo 0 def fibonacci(n): if len(memo) <= n: res = fibonacci(n-1) + fibonacci(n-2) memo.append(res) return res ...
3b913a9ac41615b691e61cbf83a4c528b3d48cff
plazotronik/test_2
/test4.py
293
3.703125
4
a=8 b=2 print('Addition:\t',a,'+',b,'=',a+b, '\nSubtraction:\t',a,'-',b,'=',a-b, '\nMultiplication:\t',a,'*',b,'=',a*b, '\nDivision:\t',a,'/',b,'=',a/b, '\nFloor Division:\t',a,'//',b,'=',a//b, '\nModulus:\t',a,'%',b,'=',a%b, '\nExponent:\t',a,'**2=',a**b)
b9389ec5335573e0c94f487cdf34307f65484831
huangxinzhen/VIPtest9_base
/objecttest/testobject4.py
1,799
4.09375
4
# -*- coding:utf-8 -*- # class A(): # def __init__(self): # self.num = 1 # def info_print(self): # print(self.num) # # class B(A): # pass # resut = B() # resut.info_print() # class Master(object): def __init__(self): self.kongfu = '[五香煎饼果子]' def make_cake(self): prin...
da4618f264058ea04f0be65a46fa2944fd1396fb
wwlorey/pacman-random-search
/world/wall_carver.py
2,798
3.609375
4
import controllers.direction as d import copy import random import world.coordinate as coord_class class WallCarver: def __init__(self, x, y, config): """Initializes the WallCarver class.""" self.config = config self.max_travel_dist = int(self.config.settings['max wall carver travel distan...
2cdb0e1933738cd57facae90e7cd195d4d9d4777
Rahul91/Exotel
/anagram2.py
343
3.75
4
count=int(raw_input()) for i in range(count): string=raw_input().split() if len(string[0])!=len(string[1]): print 'NO' else: #print (string[0]., sorted(string[1]) #a=''.join(sorted(string[0])) #b=''.join(sorted(string[1])) if ((''.join(sorted(string[0])))==(''.join(sorted(string[1])))): print 'YES' ...
aa06459df0f639538b49a4039f08e62b0bf515b6
varunkudva/Programming
/search_rotated.py
1,096
3.796875
4
""" Problem: Approach/Solution: Notes: Compexity: Time: O(n) Space: Source: None """ # find an element in a sorted rotated array def search(arr, low, high, x): mid = (low + high) / 2 if arr[mid] == x: return mid if arr[low] <= arr[mid]: # if arr[low...mid] is sorted if ar...
6ec831eed8d65e4fd987a6cdff86850811728f33
varunkudva/Programming
/lib/quicksort.py
1,074
4.25
4
"""""""""""""""""""""" Quicksort library """"""""""""""""""""" def swap(arr, left, right): arr[left], arr[right] = arr[right], arr[left] def partition(arr, left, right): """ partition the array around a pivot element, with elements < pivot to the left of pivot and elements >= pivot to the right o...
f562ee76b7d135c798e2cd028aae4f603e5be060
varunkudva/Programming
/leetcode/climbSteps.py
996
3.75
4
""" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROBLEM: APPROACH/SOLUTION: NOTES: COMPEXITY: Time: O(n) Space: Constant if considering only alphabets. O(k) where k is the character set count. SOURCE: None ~~~~~~~~~~~~~~~~~~~~~...
c60886c1289441bf9c366e1d751f340fbe346a42
varunkudva/Programming
/dynamic_programming/MaximalMatrix.py
1,090
3.71875
4
""" Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Return 6 Solution: Let S(i,j) represent the size of submatrix with all 1s with i,j being the right bottom cell in ...
ce5f77ab2c4b0b51721bb5e0dc8e42c2b2dbb7fc
varunkudva/Programming
/819_most_common.py
686
3.75
4
import heapq from collections import Counter class Solution(object): def mostCommonWord(self, paragraph, banned): """ :type paragraph: str :type banned: List[str] :rtype: str """ maxheap = [] word_counts = Counter([s.strip(',.') for s in paragraph.lower().sp...
e1815310d7e038932b0639d0550dc42fab3fb5fb
varunkudva/Programming
/dynamic_programming/coinChange.py
2,461
3.765625
4
""" Coin change problem: Given amount n and a set of denominations D = [s1, s2, ... sm], count number of ways the make change for n with denomiations. NOTE: There is infinite supply of denominations. Solution: To count the total number of ways to make change for n with m denominations - Count no. of ways to make chan...
3b060a6cb8fe9d2ebd0d38ce2a1028c01d7fe2f7
varunkudva/Programming
/patterns/undirected_graph.py
11,338
3.609375
4
""" graph.py: Simple directed graph module Ref: Algorithms by Robert Sedgewick https://algs4.cs.princeton.edu/41graph/ undirected graph templates. identical for """ from collections import defaultdict import heapq CYCLES_DG = "../tests/cycles.txt" # directed TOPO_DAG = "../tests/topo.txt" CYCLES_G = "../tests/cycle...
a763f6f9e53123988808d0ed059d067aeae293d8
varunkudva/Programming
/lib/hash.py
1,449
3.53125
4
class HashTable(object): def __init__(self, capacity=1000): self.hash = [[] for _ in range(capacity)] self.capacity = capacity self.size = 0 self.keylist = [] def hash_func(self, key): return sum([ord(c) for c in key]) % self.capacity def _set(self, key, val): ...
f5679184adfab20e70f00bc7dc68f6783ac93e73
varunkudva/Programming
/dynamic_programming/maxSubsetSum.py
819
3.8125
4
""" Largest sum contiguous subarray Given a array, find a contiguous sub-array within the array which has the largest sum. Array has both positive and negative integers Solution: Kadanes algorithm """ A = [-2, 1, -3, 4, -1, 2, 1, -5, 4] def maxSum(A): min_idx, max_idx = 0,0 max_sum = 0 sum = 0 for i ...
a0b145f7793bf03ca2da7495a36c50b4e18446e7
varunkudva/Programming
/Companies/uber_01.py
1,661
4.21875
4
#!/usr/bin/env python ''' Convert a string with digits into a literal representation of the number like: 1001 to one thousand one ''' ones_map = { 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine' } teens_map = { 10: 'ten', 11...
aeaed8de414b3a6dc826524e7d24600dbfc657d0
varunkudva/Programming
/leetcode/75_sort_colors.py
3,103
4.15625
4
""" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROBLEM Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we wi...
b919cf32e0445ec6c23b9be118b4ad0cc2cc3d9c
varunkudva/Programming
/Strings/AnagramCheck.py
926
4.09375
4
""" Problem: Check if two strings are anagrams of each other. Approach/Solution: Maintain a frequency hashmap which stores the count of occurence of characters. Increment the count while parsing the first string. Decrement the count while parsing second string. check if count is 0 for all elements in the hashmap N...
5b6c7fad1e070d8dcc32183ba0c0192f7b85c3b3
varunkudva/Programming
/dynamic_programming/LongestCommonSub.py
1,288
3.859375
4
""" Given two strings, find length of longest common subsequence and print them. subsequence can be non-contiguous in the strings. Eg: x = abcbdab, y = bdcaba. lcs is bcba of length 4. """ def lcs_simple(x, y): def print_lcs(x, y , i, j, c): if i == 0 or j == 0: return if c[i][j] == c[i...
32f53169e1244395593708a8f3dbb57c9daffec9
RocqJones/python3x_mega
/2.0File_Handling/2.2openingAndWrittingFile.py
433
3.9375
4
# if a file does not exist open() methode creates it. file = open("write1.txt",'w') # write a string file.write("Line 1: Hey there\n") file.write("Line 2: I love py") file.close() # Another file with loops and lists. file = open("write2.txt",'w') l = ["Line 1", "Line 2", "Line 3"] for items in l: file.write(items+...
f41fc4b49be2dbea8c351b41baa404e0a5c2d3a6
RocqJones/python3x_mega
/1.0Basics_Recap/1.1stringRecap.py
227
4.03125
4
x = "Hello!" print(x) print(x[0], x[1], x[2], x[3], x[4], x[5]) print(x[-1], x[-2], x[-3], x[-4], x[-5], x[-6]) # indexing print(x[0:2]) print(x[1:2]) print(x[:3]) print(x[3:]) print(x[-3:-1]) print(x[-3:-2]) print(x[-3:])
c9fff63e39f061f00f2b132e6d4027c401a7dc23
RocqJones/python3x_mega
/9.0GUI_with_Tkinter/9.3moreFuns.py
1,137
4.25
4
""" TASK. Create a Python program that expects a kilogram input value and converts that value to grams, pounds, and ounces when the user pushes the convert button. Tip: 1 kg = 1000 grams 1 kg = 2.20462 pounds 1 kg = 35.274 ounces """ from tkinter import * window = Tk() # label e1 = Label(wind...
bda7539f52773f4a44e2127b0d2e1c1667b5c2f6
stdout-se/tenant
/components/stairs.py
356
3.5
4
class Stairs: def __init__(self, floor: int): self.floor = floor # Which floor does this stair lead to? def to_json(self): json_data = { 'floor': self.floor } return json_data @classmethod def from_json(cls, json_data: dict): floor = json_data.get(...
df36761e7478c28695a0f40f57c566c0048206fd
ahmadrezare2/Dictionaries
/input n.py
91
4
4
d=dict() n=int(input("Enter your number: ")) for x in range(1,n+1): d[x]=x**2 print(d)
551f2b615670a6689a58198a3927d0c8e1f13151
Vildmusen/Advent-Of-Code
/scripts/[DAY 3] slope_maddnes.py
925
3.59375
4
from utils import * import time input = read_file_strings("day_3_input.txt") def check_impacts(input, width, step): x = 0 count = 0 for i in input: pos = x % width if(i[pos] == '#'): count += 1 x += step return count def get_half(arr): count = 0 res = [] ...
773cbb304b1603908013f7e5c19318c5055f964a
Vildmusen/Advent-Of-Code
/scripts/[DAY 1] adding_numbers.py
1,081
3.890625
4
from utils import * import time input = read_file_ints("day_1_input.txt") def find_2_matching(input, sum): cur = 1 for num1 in input: for num2 in input[cur:]: if(int(num1) + int(num2) == sum): return int(num1), int(num2) elif(int(num1) + int(num2) > sum): ...
7695fcc2eb814c0cf30aeff967412c03ade70018
sizej/FilmSeasonality
/src/movie_func.py
2,443
3.59375
4
import pandas as pd import numpy as np def genre_col(g_name, g): ''' Looks at the genre column and returns 1 if g_name is in genre ''' if g_name in g: return 1 else: return 0 def weekly_plot(col): ''' Creates 52 plot of some column ''' pass def get_dollars(s): ...
f4cf29d9312f02cad868cff972be7e20bcfa766a
Isshon-Saha/Python-Codes
/tuple.py
208
3.65625
4
age=(2,3,4,5) print(age) age1=[2,3,4,5] print(age1) age1.append(32) age1.insert(1,21) print(age1) str="Welcome to the jam" words=str.split(' ') print(words[0:3]) words.__delitem__(1) print(words)
18a314a75167e6b6df093eac35edd72f7359b678
Isshon-Saha/Python-Codes
/Threading1.py
214
3.625
4
import threading import time def func(num1,num2): print("Hello world") time.sleep(1) threads=[] for i in range(5): t=threading.Thread(target=func(2,3)) threads.append(t) t.start()
6e906c25d0b2728ff77075008d7784ef21f6ce76
viktor-edward/AdventOfCode2020
/src/day15.py
1,364
3.546875
4
import math def func1(data): return 0 def func2(data): return 0 def main(): data = [2, 15, 0, 9, 1, 20] #data = [0, 3, 6] # Test spokenWords = dict() spokenWords["2"] = 1 spokenWords["15"] = 2 spokenWords["0"] = 3 spokenWords["9"] = 4 spokenWords["1"] = 5 last...
021f69b13886ee4fff483496bda0f7ed5b8b2a30
sejinpark318/p1_201411022
/w5Main.py
1,835
3.71875
4
""" 20160330 """ def computeGrade(marks): if (marks>=90 and marks<=100): grade='A' elif (marks>=80 and marks<90): grade='B' elif (marks>=70 and marks<80): grade='C' elif (marks>=60 and markse<70): grade='D' else: grade='F' return grade ...
a6b8e587084987e2da51b7c4a60f10c22966ef9e
sejinpark318/p1_201411022
/w9main.py
1,476
3.671875
4
 def charCount(word): for c in word: if c not in mydict: mydict[c]=1 else: mydict[c]=mydict[c]+1 print mydict def charcountBar(): plt.bar(range(len(mydict)),mydict.values(),align='center') plt.xticks(range(len(mydict)),list(mydict.keys())) pl...
31b137034e1c74ae3965a0e5d3c893b047c3c1eb
rwardman/advent-of-code
/2020/day3/day3.py
800
3.75
4
data = open("day3.txt", "r").read().splitlines() openSquare = data[0][0] tree = data[0][6] def howManyTrees(right, down): position = right iterator = down trees = 0 openSquares = 0 for rowIterator in range(0, int((len(data))/down) - 1): row = data[iterator] res_row = row * 100 obstacle = res_...
8a1e25b5094609a0cf2a8605504b21cb0a400df4
mohsenjalalian/python-intro
/2/practice/1.py
291
4
4
number = input("Enter your number") number = int(number) count = 0 for i in range(1, number): if number % i == 0: count = count + 1 if number == 0: print("not prime") if count > 1 and number != 0: print("not prime") elif count <= 1 and number != 0: print("prime")
b455a7d0aaad6972485855f5c1ba5b175b9aab4c
mohsenjalalian/python-intro
/3/practice/1.py
336
3.6875
4
str_input = input() str_input = str_input.lower() str_input = str_input.replace("a", "") str_input = str_input.replace("e", "") str_input = str_input.replace("i", "") str_input = str_input.replace("u", "") str_input = str_input.replace("o", "") mystring = "" for st in str_input: mystring = mystring + "." + st ...
1cf191dd12dca57add80330d40868dff0139e6fd
SindhujaPandian/PythonProjects
/blackjack.py
5,795
3.765625
4
import random playing = True shape = ('Heart' , 'Diamond', 'Spade' , 'Clover') number = ('Ace','two','three','four','five','six','seven','eight','nine','ten','Jack','Queen','King') card_value = {'Ace':11,'two':2,'three':3,'four':4,'five':5,'six':6,'seven':7,'eight':8,'nine':9,'ten':10,'Jack':10,'Queen':10,'King':10...
558acdddd8f97e8fe74fc85656a6f51d2525dbbf
cjw0515/crawling-advanced
/m/class_ex.py
872
3.609375
4
class UserInfo: # def set_info(self, name, phone): # self.name = name # self.phone = phone def __init__(self, name, phone): self.name = name self.phone = phone def print_info(self): print("--------------------") print("name : ", self.name) print("phon...