Skip to content
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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open

Assignment_ques #12

wants to merge 21 commits into from

Conversation

shivani278
Copy link
Contributor

No description provided.

Copy link
Owner

@rkritika1508 rkritika1508 left a 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):
Copy link
Owner

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
Copy link
Owner

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.

arr.append(i)
return arr


Copy link
Owner

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__':
Copy link
Owner

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 range(r):
ans.append([])
for j in range(c):
ans[i].append(an[k])
Copy link
Owner

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)

Copy link
Owner

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))
Copy link
Owner

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"]
Copy link
Owner

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():
Copy link
Owner

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):]):
Copy link
Owner

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).

Copy link
Owner

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.

Copy link
Contributor Author

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
Copy link
Owner

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.

Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants