-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added deployment for problems an new problems
- Loading branch information
vishal
authored and
vishal
committed
Jul 25, 2024
1 parent
9f4672f
commit 6ed6800
Showing
33 changed files
with
216 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
build | ||
docker-compose-private.yml | ||
docker-compose-private.yml | ||
.env |
This file contains 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
This file contains 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,57 @@ | ||
# Interesting Array | ||
|
||
## Problem Description | ||
|
||
You have an array **A** with **N** elements. We have **two** types of operation available on this array: | ||
1. We can split an element **B** into two elements, **C** and **D,** such that `B = C + D`. | ||
2. We can merge two elements, **P** and **Q,** to one element, **R,** such that `R = P ^ Q` i.e., XOR of P and Q. | ||
|
||
You have to determine whether it is possible to convert array A to size 1, **containing a single element equal to 0** after several splits and/or merge? | ||
|
||
## Problem Constraints | ||
- 1 <= N <= 100000 | ||
- 1 <= A[i] <= 10^6 | ||
|
||
## Input | ||
The first argument is an integer array A of size N. | ||
|
||
## Output Format | ||
Return "Yes" if it is possible otherwise return "No". | ||
|
||
## Example Input | ||
|
||
Input 1: | ||
|
||
``` | ||
A = [9, 17] | ||
``` | ||
|
||
Input 2: | ||
``` | ||
A = [1] | ||
``` | ||
|
||
**Example Output** | ||
Output 1: | ||
``` | ||
Yes | ||
``` | ||
Output 2: | ||
``` | ||
No | ||
``` | ||
|
||
**Example Explanation** | ||
Explanation 1: | ||
``` | ||
Following is one possible sequence of operations - | ||
1.) Merge i.e 9 XOR 17 = 24 | ||
2.) Split 24 into two parts each of size 12 | ||
3.) Merge i.e 12 XOR 12 = 0 | ||
As there is only 1 element i.e 0. So it is possible. | ||
``` | ||
Explanation 2: | ||
``` | ||
There is no possible way to make it 0. | ||
``` | ||
``` |
This file contains 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,6 @@ | ||
Problem Name: "Intersting Arrays" | ||
Function Name: intersect | ||
Input Structure: | ||
Input Field: list<int> A | ||
Output Structure: | ||
Output Field: string ans |
This file contains 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,2 @@ | ||
2 | ||
9 7 |
This file contains 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,2 @@ | ||
1 | ||
1 |
This file contains 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,2 @@ | ||
2 | ||
1 2 |
This file contains 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,2 @@ | ||
3 | ||
3 5 6 |
This file contains 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,2 @@ | ||
10 | ||
2 4 8 16 32 64 128 256 512 1024 |
This file contains 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,2 @@ | ||
7 | ||
23 89 23 89 23 89 23 |
This file contains 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 @@ | ||
Yes |
This file contains 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 @@ | ||
No |
This file contains 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 @@ | ||
No |
This file contains 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 @@ | ||
Yes |
This file contains 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 @@ | ||
Yes |
This file contains 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 @@ | ||
No |
This file contains 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,52 @@ | ||
## Problem: Kth Smallest Sum | ||
|
||
### Description | ||
|
||
|
||
Given two arrays `A` of size `N` and `B` of size `M`, and an integer `K`, you need to create a new array `C` of size `N*M` such that each element in `C` is the sum of an element from `A` and an element from `B`. Specifically, the array `C` will be formed by calculating `A[i] + B[j]` for all `1 ≤ i ≤ N` and `1 ≤ j ≤ M`. Your task is to find the Kth smallest element in the array `C`. | ||
|
||
### Explanation | ||
To clarify, consider arrays `A` and `B` as follows: | ||
- Array `A` contains `N` elements: `A = [a1, a2, ..., aN]` | ||
- Array `B` contains `M` elements: `B = [b1, b2, ..., bM]` | ||
|
||
By adding every possible pair of elements `(ai, bj)` where `ai` is an element from `A` and `bj` is an element from `B`, you will generate a new array `C`. Array `C` will have `N * M` elements, with each element being the sum of an element from `A` and an element from `B`. | ||
|
||
For example, if `A = [1, 2]` and `B = [3, 4]`, then the possible sums (i.e., elements of array `C`) would be: | ||
- `1 + 3` | ||
- `1 + 4` | ||
- `2 + 3` | ||
- `2 + 4` | ||
|
||
So, array `C` would be `[4, 5, 5, 6]`. | ||
|
||
The challenge is to find the Kth smallest element in this array `C` efficiently given the constraints. | ||
|
||
|
||
### Constraints | ||
- `1 ≤ N ≤ 10^6`, `1 ≤ M ≤ 10^6`, `1 ≤ K ≤ min(1e9,N*M)`. | ||
- `(0 ≤ A[i] ≤ 10^4)`. | ||
- `(0 ≤ B[j] ≤ 10^4)`. | ||
- `min(N, M) ≤ 10^5`. | ||
|
||
### Output Format | ||
For each test case, print the Kth smallest element in the array `C`. | ||
|
||
### Example | ||
|
||
#### Input | ||
|
||
``` | ||
N = 3 | ||
M = 3 | ||
K = 6 | ||
A = [1,2,3] | ||
B = [4,5,6] | ||
``` | ||
|
||
#### Output | ||
|
||
``` | ||
7 | ||
``` | ||
|
This file contains 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,8 @@ | ||
Problem Name: "Kth Smallest" | ||
Function Name: solve | ||
Input Structure: | ||
Input Field: list<int> A | ||
Input Field: list<int> B | ||
Input Field: int K | ||
Output Structure: | ||
Output Field: int ans |
This file contains 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,5 @@ | ||
3 | ||
1 2 3 | ||
3 | ||
4 5 6 | ||
6 |
This file contains 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,5 @@ | ||
2 | ||
3 4 | ||
2 | ||
5 6 | ||
4 |
This file contains 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,5 @@ | ||
2 | ||
1 2 | ||
3 | ||
2 3 5 | ||
6 |
This file contains 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,5 @@ | ||
4 | ||
10 6 9 2 | ||
6 | ||
1 5 5 3 9 4 | ||
14 |
This file contains 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,5 @@ | ||
9 | ||
5 7 5 6 1 1 2 4 2 | ||
3 | ||
8 7 8 | ||
8 |
This file contains 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,5 @@ | ||
2 | ||
9 3 | ||
5 | ||
10 5 8 1 1 | ||
4 |
This file contains 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 @@ | ||
7 |
This file contains 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 @@ | ||
10 |
This file contains 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 @@ | ||
7 |
This file contains 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 @@ | ||
12 |
This file contains 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 @@ | ||
9 |
This file contains 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 @@ | ||
10 |
This file contains 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 |
---|---|---|
@@ -1,5 +1,22 @@ | ||
FROM alpine | ||
FROM node:alpine | ||
|
||
ARG DATABASE_URL | ||
|
||
COPY ./package.json /usr/src/app/package.json | ||
COPY ./package-lock.json /usr/src/app/package-lock.json | ||
COPY ./turbo.json /usr/src/app/turbo.json | ||
COPY ./packages /usr/src/app/packages | ||
COPY ./apps/boilerplate-generator /usr/src/app/apps/boilerplate-generator | ||
COPY ./apps/problems /usr/src/app/apps/problems | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY ./apps/problems /usr/src/app/problems | ||
RUN npm install | ||
|
||
RUN cd ./apps/boilerplate-generator && npm run build && PROBLEMS_DIR_PATH=/usr/src/app/apps/problems node dist/index.js | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN cd ./packages/db && DATABASE_URL=$DATABASE_URL npx prisma generate && DATABASE_URL=$DATABASE_URL MOUNT_PATH=/usr/src/app/apps/problems npx prisma db seed | ||
|
||
WORKDIR /usr/src/app |
This file contains 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
This file contains 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,4 @@ | ||
node_modules | ||
build | ||
docker-compose-private.yml | ||
.env |