Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into Aiden_EditQuestion
Browse files Browse the repository at this point in the history
  • Loading branch information
AidenLYT committed Sep 27, 2024
2 parents 2d19f51 + cf34a4c commit 86146d5
Show file tree
Hide file tree
Showing 12 changed files with 616 additions and 54 deletions.
4 changes: 2 additions & 2 deletions peer-prep-be/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN go mod download
COPY ./src ./src

# Build the Go app
RUN CGO_ENABLED=0 GOOS=linux go build -o test_run ./src/test.go
RUN CGO_ENABLED=0 GOOS=linux go build -o test_run ./src/server.go

# Second stage: Create a minimal image to run the app
FROM alpine:latest
Expand All @@ -26,7 +26,7 @@ WORKDIR /root/
COPY --from=builder /app/test_run .

# Expose the application's port
EXPOSE 8080
EXPOSE 1323

# Command to run the executable
CMD ["./test_run"]
122 changes: 122 additions & 0 deletions peer-prep-be/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
[
{
"question_title": "Reverse a String",
"question_description": "Write a function that reverses a string. The input string is given as an array of characters s.\n\nYou must do this by modifying the input array in-place with O(1) extra memory.\n\nExample 1:\nInput: s = [\"h\",\"e\",\"l\",\"l\",\"o\"]\nOutput: [\"o\",\"l\",\"l\",\"e\",\"h\"]\n\nExample 2:\nInput: s = [\"H\",\"a\",\"n\",\"n\",\"a\",\"h\"]\nOutput: [\"h\",\"a\",\"n\",\"n\",\"a\",\"H\"]\n\nConstraints:\n1 <= s.length <= 105\ns[i] is a printable ascii character.",
"question_categories": ["Strings", "Algorithms"],
"question_complexity": "Easy"
},
{
"question_title": "Linked List Cycle Detection",
"question_description": "Implement a function to detect if a linked list contains a cycle.",
"question_categories": ["Data Structures", "Algorithms"],
"question_complexity": "Easy"
},
{
"question_title": "Roman to Integer",
"question_description": "Given a roman numeral, convert it to an integer.",
"question_categories": ["Algorithms"],
"question_complexity": "Easy"
},
{
"question_title": "Add Binary",
"question_description": "Given two binary strings a and b, return their sum as a binary string.",
"question_categories": ["Bit Manipulation", "Algorithms"],
"question_complexity": "Easy"
},
{
"question_title": "Fibonacci Number",
"question_description": "The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is:\nF(0) = 0, F(1) = 1\nF(n) = F(n - 1) + F(n - 2), for n > 1.\nGiven n, calculate F(n).",
"question_categories": ["Recursion", "Algorithms"],
"question_complexity": "Easy"
},
{
"question_title": "Implement Stack using Queues",
"question_description": "Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top, pop, and empty).",
"question_categories": ["Data Structures"],
"question_complexity": "Easy"
},
{
"question_title": "Combine Two Tables",
"question_description": "Given table Person with the following columns: 1. personId (int), 2. lastName (varchar), 3. firstName (varchar), personId is the primary key.\nAnd table Address with the following columns: 1. addressId (int), 2. personId (int), 3. city (varchar), 4. state (varchar), addressId is the primary key. Write a solution to report the first name, last name, city, and state of each person in the Person table. If the address of a personId is not present in the Address table, report null instead.",
"question_categories": ["Databases"],
"question_complexity": "Easy"
},
{
"question_title": "Repeated DNA Sequences",
"question_description": "The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'.\nFor example, \"ACGAATTCCG\" is a DNA sequence. When studying DNA, it is useful to identify repeated sequences within the DNA.\nGiven a string s that represents a DNA sequence, return all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule. You may return the answer in any order.",
"question_categories": ["Algorithms", "Bit Manipulation"],
"question_complexity": "Medium"
},
{
"question_title": "Course Schedule",
"question_description": "There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai.\nFor example, the pair [0, 1], indicates that to take course 0 you have to first take course 1. Return true if you can finish all courses.",
"question_categories": ["Data Structures", "Algorithms"],
"question_complexity": "Medium"
},
{
"question_title": "LRU Cache Design",
"question_description": "Design and implement an LRU (Least Recently Used) cache.",
"question_categories": ["Data Structures"],
"question_complexity": "Medium"
},
{
"question_title": "Longest Common Subsequence",
"question_description": "Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.\n\nA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.\n\nFor example, \"ace\" is a subsequence of \"abcde\". A common subsequence of two strings is a subsequence that is common to both strings.",
"question_categories": ["Strings", "Algorithms"],
"question_complexity": "Medium"
},
{
"question_title": "Rotate Image",
"question_description": "You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).",
"question_categories": ["Arrays", "Algorithms"],
"question_complexity": "Medium"
},
{
"question_title": "Airplane Seat Assignment Probability",
"question_description": "n passengers board an airplane with exactly n seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of the passengers will:\n\n- Take their own seat if it is still available, and\n- Pick other seats randomly when they find their seat occupied\n\nReturn the probability that the nth person gets his own seat.",
"question_categories": ["Brainteaser"],
"question_complexity": "Medium"
},
{
"question_title": "Validate Binary Search Tree",
"question_description": "Given the root of a binary tree, determine if it is a valid binary search tree (BST).",
"question_categories": ["Data Structures", "Algorithms"],
"question_complexity": "Medium"
},
{
"question_title": "Sliding Window Maximum",
"question_description": "You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window.",
"question_categories": ["Arrays", "Algorithms"],
"question_complexity": "Hard"
},
{
"question_title": "N-Queen Problem",
"question_description": "The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.\n\nGiven an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order.\n\nEach solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space, respectively.",
"question_categories": ["Algorithms"],
"question_complexity": "Hard"
},
{
"question_title": "Serialize and Deserialize a Binary Tree",
"question_description": "Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.\n\nDesign an algorithm to serialize and deserialize a binary tree. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that a binary tree can be serialized to a string and this string can be deserialized to the original tree structure.",
"question_categories": ["Data Structures", "Algorithms"],
"question_complexity": "Hard"
},
{
"question_title": "Wildcard Matching",
"question_description": "Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where:\n\n- '?' Matches any single character.\n- '*' Matches any sequence of characters (including the empty sequence).\n\nThe matching should cover the entire input string (not partial).",
"question_categories": ["Strings", "Algorithms"],
"question_complexity": "Hard"
},
{
"question_title": "Chalkboard XOR Game",
"question_description": "You are given an array of integers nums represents the numbers written on a chalkboard.\n\nAlice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become 0, then that player loses. The bitwise XOR of one element is that element itself, and the bitwise XOR of no elements is 0.\n\nAlso, if any player starts their turn with the bitwise XOR of all the elements of the chalkboard equal to 0, then that player wins.\n\nReturn true if and only if Alice wins the game, assuming both players play optimally.",
"question_categories": ["Brainteaser"],
"question_complexity": "Hard"
},
{
"question_title": "Trips and Users",
"question_description": "Given table Trips:\n1. id (int)\n2. client_id (int)\n3. driver_id (int)\n4. city_id (int)\n5. status (enum)\n6. request_at (date)\nid is the primary key.\nThe table holds all taxi trips. Each trip has a unique id, while client_id and driver_id are foreign keys to the users_id at the Users table.\n\nGiven table Users:\n1. users_id (int)\n2. banned (enum)\n3. role (enum)\nusers_id is the primary key for this table.\nThe cancellation rate is computed by dividing the number of canceled requests with unbanned users by the total number of requests with unbanned users on that day.\n\nWrite a solution to find the cancellation rate of requests with unbanned users (both client and driver must not be banned) each day between \"2013-10-01\" and \"2013-10-03\". Round Cancellation Rate to two decimal points.",
"question_categories": ["Databases"],
"question_complexity": "Hard"
}
]
27 changes: 22 additions & 5 deletions peer-prep-be/go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
module github.com/CS3219-AY2425S1/cs3219-ay2425s1-project-g01/peer-prep-be

go 1.23
go 1.23.1

require github.com/labstack/echo/v4 v4.12.0
require (
github.com/go-playground/validator/v10 v10.22.1
github.com/joho/godotenv v1.5.1
github.com/labstack/echo/v4 v4.12.0
go.mongodb.org/mongo-driver v1.17.0
)

require (
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.22.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.5.0 // indirect
)
Loading

0 comments on commit 86146d5

Please sign in to comment.