- Notifications
You must be signed in to change notification settings - Fork11
efficient algorithms for general tasks with good time complexity.
License
NotificationsYou must be signed in to change notification settings
Tanmay-901/python-algorithms
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
- Check our contribution guidelines inCONTRIBUTING.md
- Star and Fork this repo.
- Clone the repo on your local machine using
git clone https://github.com/{your-username}/python-algorithms.git
. - Create a branch
git checkout -b your_new_branch_name
- Make required changes then add and commit
git add.
git commit -m "your commit message"
- Push your changes
git push origin your_new_branch_name
- Merge and send a Pull-request.
Referance: Competetive programming with python
defsum_total(n):returnint(n*(n+1)/2)
defgcd(a,b):ifa==0:returnbreturngcd(b%a,a)deflcm(a,b):prod=a*bhcf=gcd(a,b)returnprod//hcf
ifn&1==1:print('odd')else:print('even')
defmultpow(x,y):returnx<<y# x*(2^y)defdivpow(x,y):returnx>>y# x/(2^y)
defispow(n):ifn<=0:returnFalsex=ny=not(n& (n-1))returnxandy
defcntbits(n):cnt=0whilen:cnt+=1n=n& (n-1)returncnt
definttobin(n):returnstr(bin(n))[2:]defbintoint(m):returnint(m,2)
check which number occurs once(or odd number of times/doesn't has it's unique identical element) in an array:O(n)
defcheckpair(arr):# n -> araytemp=arr[0]foriinrange(1,len(arr)):temp=temp^arr[i]returntemp
About
efficient algorithms for general tasks with good time complexity.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors8
Uh oh!
There was an error while loading.Please reload this page.