Skip to content

Instantly share code, notes, and snippets.

View praveeng1618's full-sized avatar

Praveen Kumar praveeng1618

View GitHub Profile
@praveeng1618
praveeng1618 / 1929_Concatenation_of_Array.py
Created January 15, 2024 06:26
1929. Concatenation of Array Leetcode
class Solution:
def getConcatenation(self, nums: List[int]) -> List[int]:
for i in range(len(nums)):
nums.append(nums[i])
return nums
@praveeng1618
praveeng1618 / 1672_Richest_Customer_Wealth.py
Created January 15, 2024 05:43
1672. Richest Customer Wealth Leetcode
class Solution:
def maximumWealth(self, accounts: List[List[int]]) -> int:
for i in range(0, len(accounts)):
accounts[i] = sum(accounts[i])
return max(accounts)
@praveeng1618
praveeng1618 / Running_Sum _of_1d_Array.py
Created January 15, 2024 04:31
1480. Running Sum of 1d Array Leetcode
class Solution:
def runningSum(self, nums: List[int]) -> List[int]:
Sum = 0
for i in range(0,len(nums)):
Sum = Sum + nums[i]
nums[i] = Sum
return nums
@praveeng1618
praveeng1618 / TwoSum.py
Created January 9, 2024 09:09
1. Two Sum Leetcode
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
a = [() for i in range(2)]
for i in range(0,len(nums)):
for j in range(i+1,len(nums)):
if target == nums[i]+nums[j]:
return [i,j]
@praveeng1618
praveeng1618 / Parantheisis.py
Last active October 19, 2019 09:54
your'e given a string of parenthesis. return minimum number of parenthesis need to be removed , in order to make string valid. "valid" means each open parenthesis has a matching closed parenthesis
par = input()
list = []
invalid = 0
for i in range(len(par)):
if par[i] == '(':
list.append(par[i])
elif par[i] == ')':
if len(list) == 0:
invalid = invalid + 1
else:
@praveeng1618
praveeng1618 / look-and-say.py
Created October 17, 2019 18:51
A look-and-say sequence is defined as the integer sequence beginning with a single digit in which the next term is obtained by describing the previous term.
stri,n = input().split()
n = int(n)
print(stri)
def fun(init):
stri = ""
i = 0
while i < len(init):
j = i + 1
count = 1
while j <= len(init)-1 :
@praveeng1618
praveeng1618 / mysql_cheat_sheet.md
Created September 30, 2019 07:06 — forked from bradtraversy/mysql_cheat_sheet.md
MySQL Cheat Sheet

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@praveeng1618
praveeng1618 / PythagoreanTriplet.py
Last active October 17, 2019 18:53
Given a list of numbers, find if there exists a pythagorean triplet in that list. A pythagorean triplet is 3 variables a, b, c where a^2 + b^2 = c^2
import sys
t = [int(x) for x in input().split()]
if len(t) < 3 :
print(False)
sys.exit()
for i in range(len(t)):
for j in range(i+1,len(t)):
for k in range(j+1,len(t)):
if ((t[i]**2)+(t[j]**2)) == (t[k]**2):
@praveeng1618
praveeng1618 / indicesof1st&lastduplicate.py
Last active October 17, 2019 18:53
Given a sorted array, A, with possibly duplicated elements, find the indices of the first and last occurrences of a target element, x. Return -1 if the target is not found.
flist=[]
slist=[]
count = 0
A=[int(x) for x in input().split()]
target = int(input())
for x in range(len(A)) :
if target == A[x] :
flist.append(x)
count+=1
@praveeng1618
praveeng1618 / PokemonPower.py
Created September 29, 2019 06:37
maximum power
power=[]
klist=[]
def pokemon(q):
for j in range(q):
z, y = input().split()
y=int(y)
if z=='a':
power.append(y)
elif z=='i':
for s in range(len(power)):