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

Heap#99

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 52 commits intocoder2hacker:spandey1296-patch-1fromkashyap-singh:main
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
52 commits
Select commitHold shift + click to select a range
fff8cf8
Merge pull request #71 from coder2hacker/spandey1296-patch-1
spandey1296Sep 30, 2022
9482eb3
Add files via upload
spandey1296Sep 30, 2022
0d0a6ab
Merge pull request #72 from coder2hacker/spandey1296-patch-2
spandey1296Sep 30, 2022
a52b699
Tower of Hanoi using C
AnamikaSamantaSep 30, 2022
fff9173
Merge pull request #73 from AnamikaSamanta/main
spandey1296Sep 30, 2022
e7f9f94
C program using Recursion
AnamikaSamantaSep 30, 2022
5ca2ae9
Merge pull request #74 from AnamikaSamanta/main
spandey1296Sep 30, 2022
348ccec
Hashing program using C
AnamikaSamantaSep 30, 2022
8382032
Merge pull request #75 from AnamikaSamanta/main
spandey1296Sep 30, 2022
514f987
Add files via upload
spandey1296Sep 30, 2022
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;
}
49 changes: 49 additions & 0 deletionsExercise Files/01_01.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
use AdventureWorksDW2014;

-- select all columns
select * from FactInternetSales;

-- limiting results
select top 1000 * from FactInternetSales; -- in other DB's use limit 1000;

-- select using column names
SELECT [ProductKey]
,[OrderDateKey]
,[DueDateKey]
,[ShipDateKey]
,[CustomerKey]
,[PromotionKey]
,[CurrencyKey]
,[SalesTerritoryKey]
,[SalesOrderNumber]
,[SalesOrderLineNumber]
,[RevisionNumber]
,[OrderQuantity]
,[UnitPrice]
,[ExtendedAmount]
,[UnitPriceDiscountPct]
,[DiscountAmount]
,[ProductStandardCost]
,[TotalProductCost]
,[SalesAmount]
,[TaxAmt]
,[Freight]
,[CarrierTrackingNumber]
,[CustomerPONumber]
,[OrderDate]
,[DueDate]
,[ShipDate]
FROM [dbo].[FactInternetSales]


-- select some and use aliases
SELECT TOP 1000
[SalesOrderNumber] as 'OrderNumber'
,[SalesOrderLineNumber] as 'LineNumber'
,[OrderQuantity] as 'Quantity'
,[UnitPrice] as 'Price'
,[DiscountAmount] as 'Discount'
,[SalesAmount] as 'Sales'
,[TaxAmt] as 'Taxes'
,[OrderDate] as 'Date'
FROM [dbo].[FactInternetSales]
22 changes: 22 additions & 0 deletionsExercise Files/01_02.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
use AdventureWorksDW2014;


-- inner join
-- returns results only where the join condition is true
select top 1000 *
from FactInternetSales s
inner join DimProduct p on s.ProductKey = p.ProductKey

-- left join
-- returns all rows from sales, regardless of the join condition
select distinct EnglishProductName
from FactInternetSales s
left join DimProduct p on s.ProductKey = p.ProductKey
order by 1

-- add filter conditions to join
select *
from FactInternetSales s
inner join DimProduct p
ons.ProductKey = p.ProductKey
andp.StartDate > '2013-01-01'
39 changes: 39 additions & 0 deletionsExercise Files/01_03.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
use AdventureWorksDW2014;

-- basic filter with WHERE
-- get sales of a specific product only
SELECT *
FROM FactInternetSales s
INNER JOIN DimProduct p ON s.ProductKey = p.ProductKey
WHERE p.EnglishProductName = 'Road-650 Black, 62'

-- non-equi-filters
-- get all orders for 2013
SELECT *
FROM FactInternetSales s
INNER JOIN DimProduct p ON s.ProductKey = p.ProductKey
WHEREs.OrderDate >= '2013-01-01'
ANDs.OrderDate <= '2013-12-31'

-- also can use "between" for dates
SELECT *
FROM FactInternetSales s
INNER JOIN DimProduct p ON s.ProductKey = p.ProductKey
WHERE s.OrderDate BETWEEN '2013-01-01' AND '2013-12-31';

-- filter for multiple values using IN
SELECT *
FROM FactInternetSales s
INNER JOIN DimProduct p ON s.ProductKey = p.ProductKey
WHERE p.EnglishProductName in(
'Mountain-400-W Silver, 38',
'Mountain-400-W Silver, 40',
'Mountain-400-W Silver, 42',
'Mountain-400-W Silver, 46')


-- find all current and future matches with LIKE
SELECT *
FROM FactInternetSales s
INNER JOIN DimProduct p ON s.ProductKey = p.ProductKey
WHERE p.EnglishProductName LIKE 'Mountain%' --put % where you want wildcard
80 changes: 80 additions & 0 deletionsExercise Files/01_04.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
use AdventureWorksDW2014;

select OrderDate, sum(SalesAmount)
from FactInternetSales
group by OrderDate
order by OrderDate

-- simple aggregations
-- Use additional aggregations to understand more about product sales such as distribution of sales etc..
SELECT
cat.EnglishProductCategoryName 'Category'
,sub.EnglishProductSubcategoryName 'SubCategory'
,count(1) 'Count' -- How many sales where there?
,sum(s.SalesAmount) 'Sales' -- How much sales did we have?
,avg(s.SalesAmount) 'Avg_SalesAmount' -- What was the Avg sale amount?
,min(s.SalesAmount) 'Min_SaleAmount' -- What was the Min sale amount?
,max(s.SalesAmount) 'Max_SaleAmount' -- What was the Max sale amount
FROM FactInternetSales s
LEFT JOIN DimProduct p ON s.ProductKey = p.ProductKey
LEFT JOIN DimProductSubcategory sub ON p.ProductSubcategoryKey = sub.ProductSubcategoryKey
LEFT JOIN DimProductCategory cat ON sub.ProductCategoryKey = cat.ProductCategoryKey
-- must use group by in order for aggregation to work properly
GROUP BY
cat.EnglishProductCategoryName -- column aliases aren't allowed
,sub.EnglishProductSubcategoryName
ORDER BY
cat.EnglishProductCategoryName
,sub.EnglishProductSubcategoryName

-- filter to 2013 with WHERE
SELECT
YEAR(s.OrderDate) 'Year'
,cat.EnglishProductCategoryName 'Category'
,sub.EnglishProductSubcategoryName 'SubCategory'
,count(1) 'Count' -- use 1 instead of a field for faster performance
,sum(s.SalesAmount) 'Sales'
,avg(s.SalesAmount) 'Avg_Quantity'
,min(s.SalesAmount) 'Min_SaleAmount'
,max(s.SalesAmount) 'Max_SaleAmount'

FROM FactInternetSales s
INNER JOIN DimProduct p ON s.ProductKey = p.ProductKey
INNER JOIN DimProductSubcategory sub ON p.ProductSubcategoryKey = sub.ProductSubcategoryKey
INNER JOIN DimProductCategory cat ON sub.ProductCategoryKey = cat.ProductCategoryKey
-- filter
WHERE YEAR(s.OrderDate) = 2013 --use date function to parse year
-- must use group by in order for aggregation to work properly
GROUP BY
YEAR(s.OrderDate)
,cat.EnglishProductCategoryName -- column aliases aren't allowed
,sub.EnglishProductSubcategoryName
ORDER BY
cat.EnglishProductCategoryName
,sub.EnglishProductSubcategoryName

-- Only show products in 2013 that sold more than $1M USD
SELECT
cat.EnglishProductCategoryName 'Category'
,sub.EnglishProductSubcategoryName 'SubCategory'
,count(1) 'Count' -- use 1 instead of a field for faster performance
,sum(s.SalesAmount) 'Sales'
,avg(s.SalesAmount) 'Avg_Quantity'
,min(s.SalesAmount) 'Min_SaleAmount'
,max(s.SalesAmount) 'Max_SaleAmount'
FROM FactInternetSales s
INNER JOIN DimProduct p ON s.ProductKey = p.ProductKey
INNER JOIN DimProductSubcategory sub ON p.ProductSubcategoryKey = sub.ProductSubcategoryKey
INNER JOIN DimProductCategory cat ON sub.ProductCategoryKey = cat.ProductCategoryKey
-- filter
WHERE YEAR(s.OrderDate) = 2013 --use date function to parse year
-- must use group by in order for aggregation to work properly
GROUP BY
cat.EnglishProductCategoryName -- column aliases aren't allowed
,sub.EnglishProductSubcategoryName
-- use HAVING to filter after the aggregate is computed
HAVING
sum(s.SalesAmount) > 1000000
ORDER BY
cat.EnglishProductCategoryName
,sub.EnglishProductSubcategoryName
Binary file addedExercise Files/01_05.sql
View file
Open in desktop
Binary file not shown.
46 changes: 46 additions & 0 deletionsExercise Files/01_06.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
use AdventureWorksDW2014;

-- Sub Queries

-- Use a sub-query to aggregate an underlying Table
select *
from (
select sum(SalesAmount) as 'Sales', YEAR(OrderDate) as 'Yr'
from FactInternetSales
group by YEAR(OrderDate)
) YrSales

-- Create new aggregates on to of derived
select avg(Sales) as 'AvgSales'
from (
select sum(SalesAmount) as 'Sales', YEAR(OrderDate) as 'Yr'
from FactInternetSales
group by YEAR(OrderDate)
) YrSales

-- Use a subquery to test if values are IN another table
SELECT EnglishProductName 'Product'
FROM DimProduct p
WHERE p.ProductSubcategoryKey IN
(SELECT sc.ProductSubcategoryKey
FROM DimProductSubcategory sc
WHERE sc.EnglishProductSubcategoryName = 'Wheels')

-- Re-write this as a Join instead
SELECTp.EnglishProductName
FROMDimProduct p
JOINDimProductSubcategory sc ON p.ProductSubcategoryKey = sc.ProductSubcategoryKey
WHEREsc.EnglishProductSubcategoryName = 'Wheels'

-- Use EXISTS to test if the outer queries value is present in the sub-query
-- Somtimes this is the only way to express this join type
SELECT EnglishProductName 'Product'
FROM DimProduct p
WHERE EXISTS
(SELECT * -- no data is returned, only a boolean true/false
FROM DimProductSubcategory sc
WHEREp.ProductSubcategoryKey = sc.ProductSubcategoryKey
ANDsc.EnglishProductSubcategoryName = 'Wheels')



Loading

[8]ページ先頭

©2009-2025 Movatter.jp