Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
Sirajmolla merged 42 commits intocoder2hacker:spandey1296-patch-3fromkashyap-singh:main
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
42 commits
Select commitHold shift + click to select a range
2a9e8a9
quarprobing using C
AnamikaSamantaSep 30, 2022
f732ef1
Merge pull request #76 from coder2hacker/spandey1296-patch-3
spandey1296Sep 30, 2022
bc0fa57
Merge pull request #77 from AnamikaSamanta/main
spandey1296Sep 30, 2022
7b1d553
Linearprobing using C
AnamikaSamantaSep 30, 2022
38ecd08
Merge pull request #78 from AnamikaSamanta/main
spandey1296Sep 30, 2022
a33c374
Add files via upload
spandey1296Sep 30, 2022
ff891b2
Add files via upload
spandey1296Sep 30, 2022
a764d7d
Merge pull request #79 from coder2hacker/spandey1296-patch-4
spandey1296Sep 30, 2022
f3f86e2
Create ROCK_PAPER_SCISSORS.py
d-coder111Sep 30, 2022
90f08b7
Creating d-coder111.json
d-coder111Sep 30, 2022
6a6b4b1
Merge pull request #80 from d-coder111/main
spandey1296Oct 1, 2022
9d478d5
"Added Amazon SDE Sheet"
Oct 1, 2022
9af1ca4
Solution of Sheet1
Oct 1, 2022
d250f0e
solution of sheet 2
Oct 1, 2022
0480272
sheet 3 solution
Oct 1, 2022
9bf912a
Add files via upload
neha2208Oct 1, 2022
0dabf33
Add files via upload
neha2208Oct 1, 2022
2be5be5
Add files via upload
neha2208Oct 1, 2022
6a1da9b
Merge pull request #1 from neha2208/neha2208-patch-1
neha2208Oct 1, 2022
66ef547
Merge pull request #81 from akshatprogrammer/master
spandey1296Oct 1, 2022
2d893fa
Merge pull request #82 from neha2208/main
spandey1296Oct 1, 2022
1349fcd
Add files via upload
neha2208Oct 1, 2022
96f4aaa
Add files via upload
neha2208Oct 1, 2022
725aed4
Merge pull request #83 from neha2208/main
spandey1296Oct 1, 2022
6e8edf9
Add files via upload
neha2208Oct 1, 2022
ce359da
Merge pull request #84 from neha2208/main
spandey1296Oct 1, 2022
113d173
Add files via upload
neha2208Oct 1, 2022
cc80019
Merge pull request #85 from neha2208/main
spandey1296Oct 1, 2022
ba067e9
Create minimum_path_sum.py
jen-sjenOct 1, 2022
55bface
Merge pull request #1 from coder2hacker/main
d-coder111Oct 1, 2022
30ad1ef
Create RatInAMaze.java program
d-coder111Oct 1, 2022
b562198
Merge pull request #87 from d-coder111/main
spandey1296Oct 1, 2022
8ba63a5
Merge pull request #86 from jen-sjen/patch-1
spandey1296Oct 1, 2022
dc1b9b1
Disk Space Analysis
technicalrejuOct 1, 2022
31938ae
Merge pull request #88 from technicalreju/main
spandey1296Oct 1, 2022
7d36aa5
Add files via upload
kashyap-singhOct 1, 2022
15dc822
Add files via upload
kashyap-singhOct 1, 2022
6a2a2d6
Hashing Algorithm
kashyap-singhOct 2, 2022
d0a8255
Add files via upload
kashyap-singhOct 2, 2022
5bb8580
Add files via upload
kashyap-singhOct 2, 2022
bdb2def
Add files via upload
kashyap-singhOct 2, 2022
ff6e838
Add files via upload
kashyap-singhOct 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions03 string_window.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Binary file not shown.
Binary file addedAmazon/AmazonSDE3_Round1.pdf
View file
Open in desktop
Binary file not shown.
Binary file addedAmazon/AmazonSDE_AkshatJain.docx
View file
Open in desktop
Binary file not shown.
Binary file addedAmazon/sheet1.pdf
View file
Open in desktop
Binary file not shown.
Binary file addedAmazon/sheet2.pdf
View file
Open in desktop
Binary file not shown.
Binary file addedAmazon/sheet3.pdf
View file
Open in desktop
Binary file not shown.
34 changes: 34 additions & 0 deletionsDisk Space Analysis.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Binary file not shown.
Binary file addedIntroduction to control system.pdf
View file
Open in desktop
Binary file not shown.
77 changes: 77 additions & 0 deletionsLinearprobing.C
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Binary file not shown.
Binary file addedPrinciples-of-Power-Systems-by-VK-Mehta.pdf
View file
Open in desktop
Binary file not shown.
78 changes: 78 additions & 0 deletionsROCK_PAPER_SCISSORS.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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);

}

}
View file
Open in desktop
Binary file not shown.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp