- Notifications
You must be signed in to change notification settings - Fork360
Sliding Window#100
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
Sliding Window#100
Changes fromall commits
Commits
Show all changes
42 commits Select commitHold shift + click to select a range
2a9e8a9 quarprobing using C
AnamikaSamantaf732ef1 Merge pull request #76 from coder2hacker/spandey1296-patch-3
spandey1296bc0fa57 Merge pull request #77 from AnamikaSamanta/main
spandey12967b1d553 Linearprobing using C
AnamikaSamanta38ecd08 Merge pull request #78 from AnamikaSamanta/main
spandey1296a33c374 Add files via upload
spandey1296ff891b2 Add files via upload
spandey1296a764d7d Merge pull request #79 from coder2hacker/spandey1296-patch-4
spandey1296f3f86e2 Create ROCK_PAPER_SCISSORS.py
d-coder11190f08b7 Creating d-coder111.json
d-coder1116a6b4b1 Merge pull request #80 from d-coder111/main
spandey12969d478d5 "Added Amazon SDE Sheet"
9af1ca4 Solution of Sheet1
d250f0e solution of sheet 2
0480272 sheet 3 solution
9bf912a Add files via upload
neha22080dabf33 Add files via upload
neha22082be5be5 Add files via upload
neha22086a1da9b Merge pull request #1 from neha2208/neha2208-patch-1
neha220866ef547 Merge pull request #81 from akshatprogrammer/master
spandey12962d893fa Merge pull request #82 from neha2208/main
spandey12961349fcd Add files via upload
neha220896f4aaa Add files via upload
neha2208725aed4 Merge pull request #83 from neha2208/main
spandey12966e8edf9 Add files via upload
neha2208ce359da Merge pull request #84 from neha2208/main
spandey1296113d173 Add files via upload
neha2208cc80019 Merge pull request #85 from neha2208/main
spandey1296ba067e9 Create minimum_path_sum.py
jen-sjen55bface Merge pull request #1 from coder2hacker/main
d-coder11130ad1ef Create RatInAMaze.java program
d-coder111b562198 Merge pull request #87 from d-coder111/main
spandey12968ba63a5 Merge pull request #86 from jen-sjen/patch-1
spandey1296dc1b9b1 Disk Space Analysis
technicalreju31938ae Merge pull request #88 from technicalreju/main
spandey12967d36aa5 Add files via upload
kashyap-singh15dc822 Add files via upload
kashyap-singh6a2a2d6 Hashing Algorithm
kashyap-singhd0a8255 Add files via upload
kashyap-singh5bb8580 Add files via upload
kashyap-singhbdb2def Add files via upload
kashyap-singhff6e838 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
75 changes: 75 additions & 0 deletions03 string_window.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,75 @@ | ||
| #include<iostream> | ||
| #include<climits> | ||
| #include<string> | ||
| using namespace std; | ||
| string find_window(string s,string p){ | ||
| //Array as a Freq Map or you can hashmap | ||
| int FP[256] = {0}; | ||
| int FS[256] = {0}; | ||
| for(int i=0;i<p.length();i++){ | ||
| FP[ps[i]]++; | ||
| } | ||
| //Sliding Window Algorithm | ||
| int cnt = 0; | ||
| int start = 0; // left contraction | ||
| int start_idx = -1; //start_idx for best window | ||
| int min_so_far = INT_MAX; //large number | ||
| int window_size ; | ||
| for(int i=0 ; i < s.length(); i++){ | ||
| //expand the window by including current character | ||
| char ch = s[i]; | ||
| FS[ch]++; | ||
| //Count how many characters have been matched till now (string and pattern) | ||
| if(FP[ch]!=0 and FS[ch]<= FP[ch]){ | ||
| cnt += 1; | ||
| } | ||
| //another thing | ||
| //if all characters of the pattern are found in the current window then you can start contracting | ||
| if(cnt==p.length()){ | ||
| //start contracting from the left to remove unwanted characters | ||
| while(FP[s[start]]==0 or FS[s[start]] > FP[s[start]]){ | ||
| FS[s[start]]--; | ||
| start++; | ||
| } | ||
| //note. the window size | ||
| window_size = i - start + 1; | ||
| if(window_size < min_so_far){ | ||
| min_so_far = window_size; | ||
| start_idx = start; | ||
| } | ||
| } | ||
| } | ||
| if(start_idx==-1){ | ||
| return "No window found"; | ||
| } | ||
| return s.substr(start_idx,min_so_far); | ||
| } | ||
| int main(){ | ||
| string s,p; | ||
| cin>>s>>p; | ||
| cout<<find_window(s,p)<<endl; | ||
| return 0; | ||
| } |
Binary file addedAmazon/AmazonSDE2_AkshatJain.pdf
Binary file not shown.
Binary file addedAmazon/AmazonSDE3_Round1.pdf
Binary file not shown.
Binary file addedAmazon/AmazonSDE_AkshatJain.docx
Binary file not shown.
Binary file addedAmazon/sheet1.pdf
Binary file not shown.
Binary file addedAmazon/sheet2.pdf
Binary file not shown.
Binary file addedAmazon/sheet3.pdf
Binary file not shown.
34 changes: 34 additions & 0 deletionsDisk Space Analysis.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,34 @@ | ||
| #include <bits/stdc++.h> | ||
| using namespace std; | ||
| vector<int> arr; | ||
| int prevmin=-1; | ||
| int flag=0; | ||
| int x,n,q; | ||
| int sorting(int start,int end) | ||
| { | ||
| if(start+1==n) {start=0;end=end-n;} | ||
| if(start==end) return arr[start]; | ||
| return min(arr[start],sorting(start+1,end)); | ||
| } | ||
| int func(int start,int end) | ||
| { | ||
| if(flag==0) {flag++;return prevmin=sorting(start,end);} | ||
| if(arr[start-1]==prevmin) return prevmin; | ||
| return prevmin=(arr[end]<=prevmin)?prevmin:sorting(start,end); | ||
| } | ||
| int main() | ||
| { | ||
| cin>>x>>n; | ||
| int ans=0; | ||
| for(int i=0;i<n;i++) | ||
| {cin>>q;arr.push_back(q);} | ||
| for(int i=0;i<n;i++) | ||
| { | ||
| ans=max(ans,func(i,i+x-1)); | ||
| } | ||
| cout<<ans; | ||
| } |
Binary file addedFundamentals-Signals-Systems.pdf
Binary file not shown.
Binary file addedIntroduction to control system.pdf
Binary file not shown.
77 changes: 77 additions & 0 deletionsLinearprobing.C
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,77 @@ | ||
| /* Insert keys into an array with linear probing technique of collision resolution technique. */ | ||
| /* Data Structures Using C by UDIT AGARWAL */ | ||
| #include<stdio.h> | ||
| #include<conio.h> | ||
| #define MAX 10 | ||
| int a[MAX]; | ||
| void lp(int , int[]); | ||
| void lpsr(int key, int a[MAX]); | ||
| void display(int a[MAX]); | ||
| void main() | ||
| { | ||
| int i, key,ch ; | ||
| clrscr(); | ||
| for(i=0;i<MAX;i++) | ||
| a[i] = '\0'; | ||
| do{ | ||
| printf("\n\n Program for insertion/searching keys with linear probing "); | ||
| printf("\n************************************************************\n\n"); | ||
| printf("\n 1. Insert keys "); | ||
| printf("\n 2. Search key "); | ||
| printf("\n 3. Display keys "); | ||
| printf("\n 4. Exit "); | ||
| printf("\n Select operation "); | ||
| scanf("%d",&ch); | ||
| switch(ch) | ||
| { | ||
| case 1: do{ | ||
| printf("\n Enter key value [type -1 for termination] "); | ||
| scanf("%d",&key); | ||
| if (key != -1) | ||
| lp(key,a); | ||
| }while(key!=-1); | ||
| display(a); | ||
| break; | ||
| case 2:printf("\n Enter search key value "); | ||
| scanf("%d",&key); | ||
| lpsr(key,a); | ||
| break; | ||
| case 3: display(a); | ||
| break; | ||
| } | ||
| }while(ch!=4); | ||
| } | ||
| /* function lp find a location for key and insert it */ | ||
| void lp(int key, int a[MAX]) | ||
| { | ||
| int loc; | ||
| loc = key % MAX; | ||
| while (a[loc] !='\0') | ||
| loc = ++loc % MAX; | ||
| a[loc] = key; | ||
| } | ||
| /* function lpsr find a location for a key */ | ||
| void lpsr(int key, int a[MAX]) | ||
| { | ||
| int loc; | ||
| loc = key % MAX; | ||
| while ((a[loc] != key) && (a[loc] !='\0')) | ||
| loc=++loc%MAX; | ||
| if (a[loc] != '\0') | ||
| printf("\n Search successful at index %d",loc); | ||
| else | ||
| printf("\n Search unsuccessful "); | ||
| } | ||
| void display(int a[MAX]) | ||
| { | ||
| int i; | ||
| printf("\n List of keys ('0' indicate that the location is empty): \n"); | ||
| for (i=0;i<MAX;i++) | ||
| printf(" %d ",a[i]); | ||
| } |
Binary file addedPower-System-Analysis-Murthy.pdf
Binary file not shown.
Binary file addedPrinciples-of-Power-Systems-by-VK-Mehta.pdf
Binary file not shown.
78 changes: 78 additions & 0 deletionsROCK_PAPER_SCISSORS.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,78 @@ | ||
| import random | ||
| print("ROCK\nPAPER\nSCISSORS") | ||
| print("-----------------------------\n") | ||
| print("r for rock\np for paper\ns for scissors\n--------\n") | ||
| lst=['r','p','s'] | ||
| chance_taken=0 | ||
| comp_point=0 | ||
| player_point=0 | ||
| remain_chance=10 | ||
| while(remain_chance>chance_taken): | ||
| ip=input("enter your selection: ") | ||
| c=random.choice(lst) | ||
| if c==ip: | ||
| print("Both tie so 0 point to both") | ||
| elif c=='r' and ip=='p': | ||
| print(f"You entered {ip} and computer entered {c}") | ||
| print("You wins 1 point") | ||
| player_point=player_point+1 | ||
| print(f"Your score:{player_point}\t computer score:{comp_point}") | ||
| elif c=='r' and ip=='s': | ||
| print(f"You entered {ip} and computer entered {c}") | ||
| print("Computer wins 1 point") | ||
| comp_point=comp_point+1 | ||
| print(f"Your score:{player_point}\t computer score:{comp_point}") | ||
| elif c=='p' and ip=='r': | ||
| print(f"You entered {ip} and computer entered {c}") | ||
| print("Computer wins 1 point") | ||
| comp_point=comp_point+1 | ||
| print(f"Your score:{player_point}\t computer score:{comp_point}") | ||
| elif c=='p' and ip=='s': | ||
| print(f"You entered {ip} and computer entered {c}") | ||
| print("You wins 1 point") | ||
| player_point=player_point+1 | ||
| print(f"Your score:{player_point}\t computer score:{comp_point}") | ||
| elif c == 's' and ip == 'r': | ||
| print(f"You entered {ip} and computer entered {c}") | ||
| print("You wins 1 point") | ||
| player_point = player_point + 1 | ||
| print(f"Your score:{player_point}\t computer score:{comp_point}") | ||
| elif c=='s' and ip=='p': | ||
| print(f"You entered {ip} and computer entered {c}") | ||
| print("Computer wins 1 point") | ||
| comp_point=comp_point+1 | ||
| print(f"Your score:{player_point}\t computer score:{comp_point}") | ||
| else: | ||
| print("enter valid choice ") | ||
| continue | ||
| chance_taken=chance_taken+1 | ||
| print(f"you have consumed:{chance_taken} chance \t remaing chances :{remain_chance-chance_taken}") | ||
| print("-----------------------------\n") | ||
| if(comp_point==player_point): | ||
| print("Gameover\nThis is a tie") | ||
| elif comp_point>player_point: | ||
| print("Game over\nSorry..you lose..play again") | ||
| elif comp_point<player_point: | ||
| print("Game over\nHurray...You win") | ||
| print(f"Your score :{player_point}\t Computer score :{comp_point}") | ||
57 changes: 57 additions & 0 deletionsRatInAMaze.java
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,57 @@ | ||
| public class RatInAMaze { | ||
| public static boolean ratInAMaze(int maze[][]) { | ||
| int n=maze.length; | ||
| int path[][]= new int[n][n]; | ||
| return solveMaze(maze, 0, 0, path); | ||
| } | ||
| public static boolean solveMaze(int maze[][],int i,int j,int[][] path) { | ||
| int n=maze.length; | ||
| //Check if i,j cell is valid or not | ||
| if(i<0 || i>=n || j<0 || j>=n || maze[i][j]==0 || path[i][j]==1) { | ||
| return false; | ||
| } | ||
| //Include the cell in current path | ||
| path[i][j]=1; | ||
| if(i==n-1 && j==n-1) { | ||
| return true; | ||
| } | ||
| //Explore further in all directions | ||
| //top | ||
| if(solveMaze(maze, i-1, j, path)) { | ||
| return true; | ||
| } | ||
| //right | ||
| if(solveMaze(maze, i, j+1, path)) { | ||
| return true; | ||
| } | ||
| //Down | ||
| if(solveMaze(maze, i+1, j, path)) { | ||
| return true; | ||
| } | ||
| //Left | ||
| if(solveMaze(maze, i, j-1, path)) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| public static void main(String[] args) { | ||
| int maze[][]= {{1,1,0},{1,0,1},{1,1,1}}; | ||
| boolean pathPossible =ratInAMaze(maze); | ||
| System.out.println(pathPossible); | ||
| } | ||
| } |
Binary file addedSolutions-Manual-Automatic-Control-Systems-9th-Edition-by-KUO.pdf
Binary file not shown.
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.