-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assignment_ques #12
base: master
Are you sure you want to change the base?
Assignment_ques #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made some suggestions, complete them and I will merge the PR.
The assignment solutions can be in this structure.
Create a folder called Assignments. Create subfolders called, "Week 1", "Week 2" , etc. Add this code in the exact week when I gave these questions as assignments. Will help me in maintain the repo in a proper format.
for i in range(0,len(arr),2): | ||
arr[i],arr[i+1]=arr[i+1],arr[i] | ||
else: | ||
for i in range(0,len(arr)-1,2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lot of redundant code. Optimize it further. If else statements are not needed.
count=0 | ||
for i in range(len(s)): | ||
if s[i] in vowels: | ||
count+=len(string)-i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect line of code. Correct the variable name.
contest/python/The_array_dilemma.py
Outdated
arr.append(i) | ||
return arr | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This question is already present in the contest folder. Delete this.
s+=len(b) | ||
return(s) | ||
|
||
if __name__ == '__main__': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This question is already present in the contest folder. Delete this.
contest/python/reshape_2d_array.py
Outdated
for i in range(r): | ||
ans.append([]) | ||
for j in range(c): | ||
ans[i].append(an[k]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This question is already present in the contest folder. Delete this.
for i in b: | ||
if i not in arr: | ||
arr.append(i) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This question is already present in the contest folder. Delete this.
@@ -0,0 +1,8 @@ | |||
def addBinary(a, b): | |||
s=bin(int(a,2)+int(b,2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely not a good way to solve this question. You won't get this library function in any other language. This how you can solve this by simple programming logic.
@@ -0,0 +1,12 @@ | |||
def amazing(s): | |||
vowels=["a",'e','i','o','u','A','E','O','U',"I"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a string as well.
def checkPangram(str): | ||
alphabet = "abcdefghijklmnopqrstuvwxyz" | ||
for char in alphabet: | ||
if char not in str.lower(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the most optimized way to solve this question, try hashing.
@@ -0,0 +1,15 @@ | |||
def non_repeating_character(s): | |||
for i in range(len(s)): | |||
if s[i] not in(s[:i]+s[(i+1):]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the most optimized way. Complexity is O(n^2).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is giving a Time Limit Exceeded Error on Geeksforgeeks. Don't submit PRs without having an accepted solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No Dii, this is not giving any error on GFG. I have checked it again
@@ -0,0 +1,19 @@ | |||
def rearrange(string): | |||
count2=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many variables. Add proper comments on what each variable means. Make code more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use tuple unpacking while declaring variables. Makes code more readable.
No description provided.