pair<double, double> r(double px, double py, double x1, double y1, double x2, double y2) {
double a = y2 - y1;
double b = x1 - x2;
double c = x2 * y1 - x1 * y2;
double d = (a * px + b * py + c) / sqrt(a * a + b * b);
double nx = px - 2 * d * (a / sqrt(a * a + b * b));
double ny = py - 2 * d * (b / sqrt(a * a + b * b));
return {nx, ny};
}
int main() {
double ar;
cin >> ar;
double x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
double s = sqrt(ar);
vector<pair<double, double>> cr = {
{0, 0},
{0, s},
{s, s},
{s, 0},
};
set<pair<double, double>> pts(cr.begin(), cr.end());
for (const auto& c : cr) {
auto [rx, ry] = r(c.first, c.second, x1, y1, x2, y2);
pts.insert({rx, ry});
}
for (const auto& p : pts) {
cout << fixed << setprecision(2) << p.first << " " << p.second << endl;
}
return 0;
}C++
Folded area - Codevita
Telegram - t.me/codingsolution_IT
struct P {
double a, b;
P(double a = 0, double b = 0) : a(a), b(b) {}
};
P r(const P &p, double t) {
return P(p.a * cos(t) - p.b * sin(t),
p.a * sin(t) + p.b * cos(t));
}
pair<double, double> g(const vector<P> &q, double t) {
double x1 = 1e9, x2 = -1e9, y1 = 1e9, y2 = -1e9;
for (const auto &p : q) {
P s = r(p, t);
x1 = min(x1, s.a);
x2 = max(x2, s.a);
y1 = min(y1, s.b);
y2 = max(y2, s.b);
}
return {x2 - x1, y2 - y1};
}
int main() {
int n;
cin >> n;
vector<P> q(n);
for (int i = 0; i < n; ++i) {
cin >> q[i].a >> q[i].b;
}
double m = 1e9, w = 0, h = 0;
for (int i = 0; i < 360; ++i) {
double t = i * M_PI / 180.0;
auto [cw, ch] = g(q, t);
double a = cw * ch;
if (a < m) {
m = a;
w = cw;
h = ch;
}
}
if (w > h) {
swap(w, h);
}
cout << fixed << setprecision(0) << round(w) << " "
<< fixed << setprecision(0) << round(h);
return 0;
}C++
Folder Area - Codevita
Telegram - t.me/codingsolution_IT
SELECT
RoomType,
SUM(BedCount) AS 'Total Beds'
FROM
Rooms
GROUP BY
RoomType;
Telegram - t.me/codingsolution_IT
RoomType,
SUM(BedCount) AS 'Total Beds'
FROM
Rooms
GROUP BY
RoomType;
Telegram - t.me/codingsolution_IT
CODING SOLUTION - Placement Jobs & Materials pinned Deleted message
Forwarded from OFF CAMPUS JOBS INDIA
TCS NQT 2025
πBatch - 2020 - 2025
Test Date : 12th May 2025
https://www.tcsion.com/hub/national-qualifier-test/
WhatsApp - https://bit.ly/3tcjxV3
CODING SOLUTION - Placement Jobs & Materials pinned Β«TCS NQT 2025 πBatch - 2020 - 2025 Test Date : 12th May 2025 https://www.tcsion.com/hub/national-qualifier-test/ WhatsApp - https://bit.ly/3tcjxV3Β»
Forwarded from OFF CAMPUS JOBS INDIA
Navi Off Campus Drive
Job Profile : AI Solution Engineer 1
πBatch - 2022 2023 2024 2025
https://careers.navi.com/navi/jobview/ai-solutions-engineer-1-bangalore-karnataka-india-2025040217480958?source=linkedin
WhatsApp - https://bit.ly/3tcjxV3
CODING SOLUTION - Placement Jobs & Materials pinned Β«Navi Off Campus Drive Job Profile : AI Solution Engineer 1 πBatch - 2022 2023 2024 2025 https://careers.navi.com/navi/jobview/ai-solutions-engineer-1-bangalore-karnataka-india-2025040217480958?source=linkedin WhatsApp - httpβ¦Β»
Forwarded from STUDY MATERIAL - Placement Jobs & Materials
Untitled document (1).pdf
124.1 KB
TCS NQT 2025 | Full Mock Test PDF
π₯ 30+ High-Quality Questions | β With Answers
π Numerical | βοΈ Verbal | π§ Reasoning | π» Coding
PDF Based on Real Exam Pattern
Boost your prep with the most expected questions!
Shared by: STUDY MATERIAL - Placement Jobs & Materials
Join for More Materials & Updates:
β‘οΈ https://t.me/studymaterial_IT
π₯ 30+ High-Quality Questions | β With Answers
π Numerical | βοΈ Verbal | π§ Reasoning | π» Coding
PDF Based on Real Exam Pattern
Boost your prep with the most expected questions!
Shared by: STUDY MATERIAL - Placement Jobs & Materials
Join for More Materials & Updates:
β‘οΈ https://t.me/studymaterial_IT
def update_list(val, items=[]):
items.append(val)
return items
print("Call 1:", update_list(10))
print("Call 2:", update_list(20))
def fresh_list(val, items=None):
if items is None:
items = []
items.append(val)
return items
print("Call 3:", fresh_list(30))
print("Call 4:", fresh_list(40))
Options:
A.
Call 1: [10]
Call 2: [10, 20]
Call 3: [30]
Call 4: [30, 40]
B.
Call 1: [10]
Call 2: [20]
Call 3: [30]
Call 4: [40]
C.
Call 1: [10]
Call 2: [10, 20]
Call 3: [30]
Call 4: [30]
D.
Error due to list mutation
Answer: A
CODING SOLUTION - Placement Jobs & Materials pinned Β«def update_list(val, items=[]): items.append(val) return items print("Call 1:", update_list(10)) print("Call 2:", update_list(20)) def fresh_list(val, items=None): if items is None: items = [] items.append(val) return itemsβ¦Β»
π₯ PLACEMENT PREP COMBO PACK π₯
Boost your logic + aptitude + coding skills in 5 mins!
1. Aptitude β Profit & Loss
A shopkeeper buys an item for Rs. 240 and sells it at a profit of 25%.
Selling Price = ?
Solution:
SP = CP Γ (1 + Profit%)
= 240 Γ (1 + 25/100)
= 240 Γ 1.25 = Rs. 300
2. Python Concept β List vs Tuple
List: Mutable
Example:
You can modify β
Tuple: Immutable
Example:
You cannot modify elements.
3. Mini Coding Task β Count Vowels in String
Output: 3
Boost your logic + aptitude + coding skills in 5 mins!
1. Aptitude β Profit & Loss
A shopkeeper buys an item for Rs. 240 and sells it at a profit of 25%.
Selling Price = ?
Solution:
SP = CP Γ (1 + Profit%)
= 240 Γ (1 + 25/100)
= 240 Γ 1.25 = Rs. 300
2. Python Concept β List vs Tuple
List: Mutable
Example:
my_list = [1, 2, 3]You can modify β
my_list[0] = 10Tuple: Immutable
Example:
my_tuple = (1, 2, 3)You cannot modify elements.
3. Mini Coding Task β Count Vowels in String
def count_vowels(s): return sum(1 for ch in s.lower() if ch in 'aeiou') # Example: count_vowels("placement") β Output: 3
CODING SOLUTION - Placement Jobs & Materials pinned Β«π₯ PLACEMENT PREP COMBO PACK π₯ Boost your logic + aptitude + coding skills in 5 mins! 1. Aptitude β Profit & Loss A shopkeeper buys an item for Rs. 240 and sells it at a profit of 25%. Selling Price = ? Solution: SP = CP Γ (1 + Profit%) = 240 Γ (1 + 25/100)β¦Β»
π₯Problem Statementπ₯
A robot is stuck in a maze represented by an NxN grid. The grid contains:
'S': Starting point
'E': Ending point
'.': Empty cell (can move)
'#': Wall (cannot move)
'P': Portal (teleports to the next portal clockwise)
Rules:
Robot can move up, down, left, right.
If robot steps on 'P', it is instantly teleported to the next portal (clockwise).
You need to find the minimum number of steps to reach 'E' from 'S'.
C++
Telegram : http://t.me/codingsolution_IT
A robot is stuck in a maze represented by an NxN grid. The grid contains:
'S': Starting point
'E': Ending point
'.': Empty cell (can move)
'#': Wall (cannot move)
'P': Portal (teleports to the next portal clockwise)
Rules:
Robot can move up, down, left, right.
If robot steps on 'P', it is instantly teleported to the next portal (clockwise).
You need to find the minimum number of steps to reach 'E' from 'S'.
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
int N;
vector<vector<char>> grid;
vector<pii> portals;
bool isValid(int x, int y, vector<vector<bool>>& visited) {
return x >= 0 && x < N && y >= 0 && y < N && !visited[x][y] && grid[x][y] != '#';
}
pii getNextPortal(pii current) {
for (int i = 0; i < portals.size(); i++) {
if (portals[i] == current) {
return portals[(i + 1) % portals.size()];
}
}
return current;
}
int shortestPathWithPortals() {
pii start, end;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (grid[i][j] == 'S') start = {i, j};
else if (grid[i][j] == 'E') end = {i, j};
else if (grid[i][j] == 'P') portals.push_back({i, j});
}
}
vector<vector<bool>> visited(N, vector<bool>(N, false));
queue<pair<pii, int>> q;
q.push({start, 0});
visited[start.first][start.second] = true;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
while (!q.empty()) {
pii curr = q.front().first;
int steps = q.front().second;
q.pop();
if (curr == end) return steps;
for (int d = 0; d < 4; d++) {
int nx = curr.first + dx[d];
int ny = curr.second + dy[d];
if (isValid(nx, ny, visited)) {
if (grid[nx][ny] == 'P') {
pii tele = getNextPortal({nx, ny});
if (!visited[tele.first][tele.second]) {
visited[tele.first][tele.second] = true;
q.push({tele, steps + 1});
}
} else {
visited[nx][ny] = true;
q.push({{nx, ny}, steps + 1});
}
}
}
}
return -1;
}
int main() {
cin >> N;
grid = vector<vector<char>>(N, vector<char>(N));
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
cin >> grid[i][j];
cout << shortestPathWithPortals() << endl;
return 0;
}
C++
Telegram : http://t.me/codingsolution_IT
CODING SOLUTION - Placement Jobs & Materials pinned Β«π₯Problem Statementπ₯ A robot is stuck in a maze represented by an NxN grid. The grid contains: 'S': Starting point 'E': Ending point '.': Empty cell (can move) '#': Wall (cannot move) 'P': Portal (teleports to the next portal clockwise) Rules: Robotβ¦Β»