- Notifications
You must be signed in to change notification settings - Fork360
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
Uh oh!
There was an error while loading.Please reload this page.
Merged
Heap#99
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
spandey12969482eb3 Add files via upload
spandey12960d0a6ab Merge pull request #72 from coder2hacker/spandey1296-patch-2
spandey1296a52b699 Tower of Hanoi using C
AnamikaSamantafff9173 Merge pull request #73 from AnamikaSamanta/main
spandey1296e7f9f94 C program using Recursion
AnamikaSamanta5ca2ae9 Merge pull request #74 from AnamikaSamanta/main
spandey1296348ccec Hashing program using C
AnamikaSamanta8382032 Merge pull request #75 from AnamikaSamanta/main
spandey1296514f987 Add files via upload
spandey12962a9e8a9 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; | ||
| } |
49 changes: 49 additions & 0 deletionsExercise Files/01_01.sql
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,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
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,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
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,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
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,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
Binary file not shown.
46 changes: 46 additions & 0 deletionsExercise Files/01_06.sql
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,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') | ||
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.