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

Commit4a7ff4d

Browse files
authored
Merge pull request#103 from kashyap-singh/main
BST
2 parentsff891b2 +ff6e838 commit4a7ff4d

File tree

51 files changed

+755
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+755
-0
lines changed

‎03 string_window.cpp‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include<iostream>
2+
#include<climits>
3+
#include<string>
4+
usingnamespacestd;
5+
6+
stringfind_window(string s,string p){
7+
8+
9+
//Array as a Freq Map or you can hashmap
10+
int FP[256] = {0};
11+
int FS[256] = {0};
12+
13+
for(int i=0;i<p.length();i++){
14+
FP[ps[i]]++;
15+
}
16+
17+
//Sliding Window Algorithm
18+
int cnt =0;
19+
int start =0;// left contraction
20+
int start_idx = -1;//start_idx for best window
21+
int min_so_far = INT_MAX;//large number
22+
int window_size ;
23+
24+
25+
for(int i=0 ; i < s.length(); i++){
26+
//expand the window by including current character
27+
char ch = s[i];
28+
FS[ch]++;
29+
30+
//Count how many characters have been matched till now (string and pattern)
31+
if(FP[ch]!=0and FS[ch]<= FP[ch]){
32+
cnt +=1;
33+
}
34+
35+
//another thing
36+
//if all characters of the pattern are found in the current window then you can start contracting
37+
if(cnt==p.length()){
38+
39+
//start contracting from the left to remove unwanted characters
40+
41+
while(FP[s[start]]==0or FS[s[start]] > FP[s[start]]){
42+
FS[s[start]]--;
43+
start++;
44+
}
45+
46+
//note. the window size
47+
window_size = i - start +1;
48+
if(window_size < min_so_far){
49+
min_so_far = window_size;
50+
start_idx = start;
51+
}
52+
53+
}
54+
55+
}
56+
if(start_idx==-1){
57+
return"No window found";
58+
}
59+
return s.substr(start_idx,min_so_far);
60+
}
61+
62+
63+
64+
intmain(){
65+
66+
string s,p;
67+
cin>>s>>p;
68+
69+
70+
cout<<find_window(s,p)<<endl;
71+
72+
73+
74+
return0;
75+
}

‎Amazon/AmazonSDE2_AkshatJain.pdf‎

346 KB
Binary file not shown.

‎Amazon/AmazonSDE3_Round1.pdf‎

94.1 KB
Binary file not shown.

‎Amazon/AmazonSDE_AkshatJain.docx‎

78.7 KB
Binary file not shown.

‎Amazon/sheet1.pdf‎

3.3 MB
Binary file not shown.

‎Amazon/sheet2.pdf‎

11 MB
Binary file not shown.

‎Amazon/sheet3.pdf‎

692 KB
Binary file not shown.

‎Disk Space Analysis.cpp‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include<bits/stdc++.h>
2+
usingnamespacestd;
3+
vector<int> arr;
4+
int prevmin=-1;
5+
int flag=0;
6+
int x,n,q;
7+
8+
intsorting(int start,int end)
9+
{
10+
if(start+1==n) {start=0;end=end-n;}
11+
if(start==end)return arr[start];
12+
returnmin(arr[start],sorting(start+1,end));
13+
}
14+
15+
intfunc(int start,int end)
16+
{
17+
if(flag==0) {flag++;return prevmin=sorting(start,end);}
18+
if(arr[start-1]==prevmin)return prevmin;
19+
return prevmin=(arr[end]<=prevmin)?prevmin:sorting(start,end);
20+
21+
}
22+
23+
intmain()
24+
{
25+
cin>>x>>n;
26+
int ans=0;
27+
for(int i=0;i<n;i++)
28+
{cin>>q;arr.push_back(q);}
29+
for(int i=0;i<n;i++)
30+
{
31+
ans=max(ans,func(i,i+x-1));
32+
}
33+
cout<<ans;
34+
}

‎Fundamentals-Signals-Systems.pdf‎

7.91 MB
Binary file not shown.

‎Introduction to control system.pdf‎

9.99 MB
Binary file not shown.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp