- Notifications
You must be signed in to change notification settings - Fork360
Rainwater Problem#120
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
36 commits Select commitHold shift + click to select a range
4aaa111 Added array right rotated logic
Peeyush199993bbd628 Hill_Cipher.java
harshitgupta2000904320e Caesar_cipher.py
harshitgupta200053193d4 KMP.java
harshitgupta2000786583f Heap_sort.java
harshitgupta20006ff4d61 feat: Added personal content
godsakanieeb4102 Added solution using filter and includes
Peeyush199991e3e36a Create SnakeGame.py
gauravtrivedi967b2fd605 Create CreditRisk.py
gauravtrivedi9674f0c7b3 Create ChatBot.py
gauravtrivedi9671308e9b Create HindiDataCleaning.py
gauravtrivedi9673e65cb5 Merge pull request #107 from gauravtrivedi967/patch-3
Sirajmolla58790b0 Merge pull request #108 from gauravtrivedi967/patch-4
Sirajmollad9e05bf Merge pull request #106 from gauravtrivedi967/patch-2
Sirajmollaab70cf3 Merge pull request #105 from gauravtrivedi967/patch-1
Sirajmollab1e2d3e Merge pull request #104 from Peeyush19999/patch-2
Sirajmolla4a7ff4d Merge pull request #103 from kashyap-singh/main
Sirajmollabaa1c96 Merge pull request #102 from godsakani/hacktoberfes
Sirajmolla95918a2 Merge pull request #101 from kashyap-singh/main
Sirajmolla3e0bda5 Merge pull request #100 from kashyap-singh/main
Sirajmolla6958b76 Merge pull request #98 from kashyap-singh/main
Sirajmolla1f79665 Merge pull request #97 from harshitgupta2000/patch-3
Sirajmolla63e795c Merge pull request #96 from harshitgupta2000/patch-2
Sirajmollad3584bc Merge pull request #95 from harshitgupta2000/patch-1
Sirajmolla9b016f4 Merge pull request #94 from harshitgupta2000/main
Sirajmolla1d27e3b Merge pull request #93 from Peeyush19999/patch-1
Sirajmollaa20f9ce Create Detect Capital
bishalp22b3215cc Added a java program to reverse an array
aphsavii9b507b7 Merge pull request #114 from coder2hacker/spandey1296-patch-1
Sirajmolla45bb213 Merge pull request #113 from coder2hacker/spandey1296-patch-3
Sirajmolla02da43e Merge pull request #112 from coder2hacker/spandey1296-patch-4
Sirajmolla502ce55 Merge pull request #111 from aphsavii/main
Sirajmolla32fa732 Merge pull request #110 from coder2hacker/spandey1296-patch-2
Sirajmolla03733eb Merge pull request #109 from bishalp22/patch-5
Sirajmolla03c47d6 Add files via upload
kashyap-singh674a2a5 Add files via upload
kashyap-singhFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions07 rainwater-trap.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #include <iostream> | ||
| #include <vector> | ||
| using namespace std; | ||
| int trappedWater(vector<int> heights) { | ||
| int n = heights.size(); | ||
| if(n<=2){ | ||
| return 0; | ||
| } | ||
| vector<int> left(n,0), right(n,0); | ||
| left[0] = heights[0]; | ||
| right[n-1] = heights[n-1]; | ||
| for(int i=1;i<n;i++){ | ||
| left[i] = max(left[i-1],heights[i]); | ||
| right[n-i-1] = max(right[n-i],heights[n-i-1]); | ||
| } | ||
| int water = 0; | ||
| for(int i=0;i<n;i++){ | ||
| water += min(left[i],right[i]) - heights[i]; | ||
| } | ||
| return water; | ||
| } | ||
| int main() { | ||
| int n; | ||
| cin>>n; | ||
| vector<int> water; | ||
| for(int i=0;i<n;i++) | ||
| { | ||
| int a; | ||
| cin>>a; | ||
| water.push_back(a); | ||
| } | ||
| cout<<trappedWater(water)<<endl; | ||
| return 0; | ||
| } |
110 changes: 110 additions & 0 deletionsChatBot.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| #%% | ||
| import pyttsx3 #pip install pyttsx3 | ||
| import speech_recognition as sr #pip install speechRecognition | ||
| import datetime | ||
| import wikipedia #pip install wikipedia | ||
| import webbrowser | ||
| import os | ||
| import smtplib | ||
| engine = pyttsx3.init('sapi5') | ||
| voices = engine.getProperty('voices') | ||
| # print(voices[1].id) | ||
| engine.setProperty('voice', voices[0].id) | ||
| def speak(audio): | ||
| engine.say(audio) | ||
| engine.runAndWait() | ||
| def wishMe(): | ||
| hour = int(datetime.datetime.now().hour) | ||
| if hour>=0 and hour<12: | ||
| speak("Good Morning!") | ||
| elif hour>=12 and hour<18: | ||
| speak("Good Afternoon!") | ||
| else: | ||
| speak("Good Evening!") | ||
| speak("I am Lucifer Sir. Please tell me how may I help you") | ||
| def takeCommand(): | ||
| #It takes microphone input from the user and returns string output | ||
| r = sr.Recognizer() | ||
| with sr.Microphone() as source: | ||
| print("Listening...") | ||
| r.pause_threshold = 1 | ||
| audio = r.listen(source) | ||
| try: | ||
| print("Recognizing...") | ||
| query = r.recognize_google(audio, language='en-in') | ||
| print(f"User said: {query}\n") | ||
| except Exception as e: | ||
| # print(e) | ||
| print("Say that again please...") | ||
| return "None" | ||
| return query | ||
| def sendEmail(to, content): | ||
| server = smtplib.SMTP('smtp.gmail.com', 587) | ||
| server.ehlo() | ||
| server.starttls() | ||
| server.login('youremail@gmail.com', 'your-password') | ||
| server.sendmail('youremail@gmail.com', to, content) | ||
| server.close() | ||
| if __name__ == "__main__": | ||
| wishMe() | ||
| while True: | ||
| # if 1: | ||
| query = takeCommand().lower() | ||
| # Logic for executing tasks based on query | ||
| if 'wikipedia' in query: | ||
| speak('Searching Wikipedia...') | ||
| query = query.replace("wikipedia", "") | ||
| results = wikipedia.summary(query, sentences=2) | ||
| speak("According to Wikipedia") | ||
| print(results) | ||
| speak(results) | ||
| elif 'open youtube' in query: | ||
| webbrowser.open("youtube.com") | ||
| elif 'open google' in query: | ||
| webbrowser.open("google.com") | ||
| elif 'open stackoverflow' in query: | ||
| webbrowser.open("stackoverflow.com") | ||
| elif 'play music' in query: | ||
| music_dir = 'D:\\Non Critical\\songs\\Favorite Songs2' | ||
| songs = os.listdir(music_dir) | ||
| print(songs) | ||
| os.startfile(os.path.join(music_dir, songs[0])) | ||
| elif 'the time' in query: | ||
| strTime = datetime.datetime.now().strftime("%H:%M:%S") | ||
| speak(f"Sir, the time is {strTime}") | ||
| elif 'open code' in query: | ||
| codePath = "C:\\Users\\GAURAV\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe" | ||
| os.startfile(codePath) | ||
| elif 'email to harry' in query: | ||
| try: | ||
| speak("What should I say?") | ||
| content = takeCommand() | ||
| to = "harryyourEmail@gmail.com" | ||
| sendEmail(to, content) | ||
| speak("Email has been sent!") | ||
| except Exception as e: | ||
| print(e) | ||
| speak("Sorry my friend gaurav. I am not able to send this email") |
116 changes: 116 additions & 0 deletionsCreditRisk.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| #%% | ||
| import warnings | ||
| warnings.filterwarnings('ignore') | ||
| import os | ||
| import numpy as np | ||
| import pandas as pd | ||
| import scipy.stats as st | ||
| import statsmodels.api as sm | ||
| import matplotlib.pyplot as plt | ||
| from sklearn import linear_model | ||
| from sklearn.metrics import mean_squared_error, r2_score, confusion_matrix, accuracy_score | ||
| from sklearn.model_selection import train_test_split | ||
| from sklearn.metrics import roc_curve | ||
| from sklearn.metrics import roc_auc_score | ||
| # %% | ||
| os.chdir('D:/machine_learning/DATA_SET/credit_risk') | ||
| df_a = pd.read_csv('credit_risk.csv') | ||
| df_a.head() | ||
| # %% | ||
| df_a.isnull().sum() | ||
| # %% | ||
| df_a.dropna(axis=0,inplace=True) | ||
| df_a.isnull().sum() | ||
| # %% | ||
| df_a.dtypes | ||
| # %% | ||
| df_a["CoapplicantIncome"] = df_a["CoapplicantIncome"].astype('float') | ||
| df_a["ApplicantIncome"] = df_a["ApplicantIncome"].astype('float') | ||
| print("AFTER CHANGING INT & OBJECT TO FLOAT") | ||
| df_a.dtypes | ||
| # %% | ||
| df_a["Dependents"].value_counts() | ||
| # %% | ||
| cleanup_nums = { | ||
| "Married": {"Yes": 1, "No": 0}, | ||
| "Self_Employed": {"Yes": 1, "No": 0}, | ||
| "Property_Area": {"Rural":0, "Urban":1, "Semiurban":2}, | ||
| "Education": {"Graduate": 1, "Not Graduate": 0}, | ||
| "Loan_Status": { "Y": 1, "N": 0}, | ||
| "Gender": { "Male": 1, "Female": 0}, | ||
| "Dependents": { "0": 0, "1": 1, "2": 2, "3+": 3}, | ||
| } | ||
| df_a.replace(cleanup_nums, inplace=True) | ||
| df_a.head() | ||
| # %% | ||
| df_corr = df_a[[ 'Gender', 'Married', 'Dependents', 'Education', | ||
| 'Self_Employed', 'ApplicantIncome', 'CoapplicantIncome', 'LoanAmount', | ||
| 'Loan_Amount_Term', 'Credit_History', 'Property_Area','Loan_Status']] | ||
| df_corr.head() | ||
| # %% | ||
| plt.imshow(df_corr.corr(), cmap=plt.cm.Blues , interpolation='nearest') | ||
| cmap='coolwarm' | ||
| plt.colorbar() | ||
| tick_marks = [i for i in range(len(df_corr.columns))] | ||
| plt.xticks(tick_marks, df_corr.columns, rotation='vertical') | ||
| plt.yticks(tick_marks, df_corr.columns) | ||
| plt.show() | ||
| #%% | ||
| boolean_col = 'Loan_Status' | ||
| cols = ['Gender','Married','Dependents','Education','Self_Employed', | ||
| 'ApplicantIncome', 'CoapplicantIncome', 'Credit_History' | ||
| ] | ||
| xTrain = df_a[cols].values | ||
| yTrain = df_a[boolean_col].values | ||
| # %% | ||
| st.chisqprob = lambda chisq, df: st.chi2.sf(chisq, df) | ||
| model = sm.Logit( yTrain, xTrain ) | ||
| result = model.fit() | ||
| result.summary( xname=cols, yname=boolean_col,title='Logit Model', alpha=1) | ||
| # %% | ||
| def calculate_accuracy( predictions, real): | ||
| correct = 0 | ||
| for i in range(len(predictions)): | ||
| if round(predictions[i]) == round(real[i]): | ||
| correct += 1 | ||
| return correct * 1.0 / len(predictions) | ||
| # %% | ||
| train_predictions = result.predict(xTrain) | ||
| train_accuracy = calculate_accuracy( train_predictions, yTrain ) | ||
| print("Train Accuracy: ", train_accuracy * 100 ) | ||
| # %% | ||
| train_predictions = (train_predictions > 0.5) | ||
| train_cm = confusion_matrix( yTrain, train_predictions, labels = [1.0, 0.0]) | ||
| print(train_cm ) | ||
| # %% | ||
| labels = ['0', '1'] | ||
| cm = train_cm | ||
| fig = plt.figure() | ||
| ax = fig.add_subplot(111) | ||
| cax = ax.matshow(cm, cmap='viridis') | ||
| plt.title('Confusion matrix') | ||
| fig.colorbar(cax) | ||
| ax.set_xticklabels([''] + labels) | ||
| ax.set_yticklabels([''] + labels) | ||
| r=0 | ||
| c=0 | ||
| for listItem in cm: | ||
| for cellItem in listItem: | ||
| ax.text(c,r, cellItem, va='center', ha='center', color='r') | ||
| c+=1 | ||
| c=0 | ||
| r+=1 | ||
| plt.xlabel('Actual label') | ||
| plt.ylabel('Predicted label') | ||
| plt.show() | ||
| # %% |
42 changes: 42 additions & 0 deletionsDetect Capital
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| Detect Capital | ||
| Level-Easy | ||
| We define the usage of capitals in a word to be right when one of the following cases holds: | ||
| All letters in this word are capitals, like "USA". | ||
| All letters in this word are not capitals, like "leetcode". | ||
| Only the first letter in this word is capital, like "Google". | ||
| Given a string word, return true if the usage of capitals in it is right. | ||
| Example 1: | ||
| Input: word = "USA" | ||
| Output: true | ||
| Example 2: | ||
| Input: word = "FlaG" | ||
| Output: false | ||
| Constraints: | ||
| 1 <= word.length <= 100 | ||
| word consists of lowercase and uppercase English letters. | ||
| Time Complexity-o(n) | ||
| Space Complexity-o(1) | ||
| Java Solution | ||
| class Solution { | ||
| public boolean detectCapitalUse(String word) { | ||
| if(word.length()>=2 && word.charAt(0)>=97 && word.charAt(0)<=123 && word.charAt(1)>=65 && word.charAt(1)<=91) | ||
| return false; | ||
| for(int i=1;i<word.length()-1;i++){ | ||
| if(word.charAt(i)>=65 && word.charAt(i)<=91){ | ||
| if(word.charAt(i+1)>=65 && word.charAt(i+1)<=91); | ||
| else | ||
| return false; | ||
| } | ||
| else{ | ||
| if(word.charAt(i+1)>=97 && word.charAt(i+1)<=123); | ||
| else | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
| } |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.