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

Commit446c6ab

Browse files
authored
Merge pull request#99 from kashyap-singh/main
Heap
2 parentse7ee3d8 +ff6e838 commit446c6ab

File tree

81 files changed

+1865
-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.

81 files changed

+1865
-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+
}

‎Exercise Files/01_01.sql‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use AdventureWorksDW2014;
2+
3+
-- select all columns
4+
select*from FactInternetSales;
5+
6+
-- limiting results
7+
selecttop1000*from FactInternetSales;-- in other DB's use limit 1000;
8+
9+
-- select using column names
10+
SELECT [ProductKey]
11+
,[OrderDateKey]
12+
,[DueDateKey]
13+
,[ShipDateKey]
14+
,[CustomerKey]
15+
,[PromotionKey]
16+
,[CurrencyKey]
17+
,[SalesTerritoryKey]
18+
,[SalesOrderNumber]
19+
,[SalesOrderLineNumber]
20+
,[RevisionNumber]
21+
,[OrderQuantity]
22+
,[UnitPrice]
23+
,[ExtendedAmount]
24+
,[UnitPriceDiscountPct]
25+
,[DiscountAmount]
26+
,[ProductStandardCost]
27+
,[TotalProductCost]
28+
,[SalesAmount]
29+
,[TaxAmt]
30+
,[Freight]
31+
,[CarrierTrackingNumber]
32+
,[CustomerPONumber]
33+
,[OrderDate]
34+
,[DueDate]
35+
,[ShipDate]
36+
FROM [dbo].[FactInternetSales]
37+
38+
39+
-- select some and use aliases
40+
SELECTTOP1000
41+
[SalesOrderNumber]as'OrderNumber'
42+
,[SalesOrderLineNumber]as'LineNumber'
43+
,[OrderQuantity]as'Quantity'
44+
,[UnitPrice]as'Price'
45+
,[DiscountAmount]as'Discount'
46+
,[SalesAmount]as'Sales'
47+
,[TaxAmt]as'Taxes'
48+
,[OrderDate]as'Date'
49+
FROM [dbo].[FactInternetSales]

‎Exercise Files/01_02.sql‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use AdventureWorksDW2014;
2+
3+
4+
-- inner join
5+
-- returns results only where the join condition is true
6+
select top1000*
7+
from FactInternetSales s
8+
inner join DimProduct pons.ProductKey=p.ProductKey
9+
10+
-- left join
11+
-- returns all rows from sales, regardless of the join condition
12+
select distinct EnglishProductName
13+
from FactInternetSales s
14+
left join DimProduct pons.ProductKey=p.ProductKey
15+
order by1
16+
17+
-- add filter conditions to join
18+
select*
19+
from FactInternetSales s
20+
inner join DimProduct p
21+
ons.ProductKey=p.ProductKey
22+
andp.StartDate>'2013-01-01'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp