Skip to content

Instantly share code, notes, and snippets.

View praveeng1618's full-sized avatar

Praveen Kumar praveeng1618

View GitHub Profile
@praveeng1618
praveeng1618 / ProductOfRemaining.py
Created September 29, 2019 06:19
Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].
arr = [int(x) for x in input().split()]
res=[]
def multiply(lst):
j = 1
for i in range(len(lst)):
j = j * lst[i]
return j
def product(arr,k,p):
arr[i]=1
@praveeng1618
praveeng1618 / longsubstring.py
Created September 17, 2019 17:28
In a given string , we have to find the length of longest sub string with out repeating characters
r=input("enter string")
nums = list(r)
a=[[]]
def subsets(nums):
for i in range(len(nums)+1):
for j in range(i+1,len(nums)+1):
sub = nums[i:j]
a.append(sub)
return a
subsets(nums)