๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
class Result {
public:
static vector<string> reformatDate(vector<string> dates) {
vector<string> outputDate;
for (const string& tempStr : dates) {
string formattedDate = tempStr;
size_t pos = formattedDate.find_first_of("0123456789");
if (pos != string::npos) {
formattedDate = formattedDate.substr(pos);
struct tm tempTm;
if (strptime(formattedDate.c_str(), "%d %b %Y", &tempTm) != nullptr) {
int year = tempTm.tm_year + 1900;
if (year >= 1900 && year <= 2100) {
ostringstream oss;
oss << year << "-" << setw(2) << setfill('0') << tempTm.tm_mon + 1 << "-" << setw(2) << setfill('0') << tempTm.tm_mday;
outputDate.push_back(oss.str());
} else {
cout << "Year out of range" << endl;
}
}
}
}
return outputDate;
}
};
int main() {
int datesCount;
cin >> datesCount;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
vector<string> dates;
for (int i = 0; i < datesCount; ++i) {
string date;
getline(cin, date);
dates.push_back(date);
}
vector<string> result = Result::reformatDate(dates);
for (const string& formattedDate : result) {
cout << formattedDate << endl;
}
return 0;
}
Goldman Sachs โ
public:
static vector<string> reformatDate(vector<string> dates) {
vector<string> outputDate;
for (const string& tempStr : dates) {
string formattedDate = tempStr;
size_t pos = formattedDate.find_first_of("0123456789");
if (pos != string::npos) {
formattedDate = formattedDate.substr(pos);
struct tm tempTm;
if (strptime(formattedDate.c_str(), "%d %b %Y", &tempTm) != nullptr) {
int year = tempTm.tm_year + 1900;
if (year >= 1900 && year <= 2100) {
ostringstream oss;
oss << year << "-" << setw(2) << setfill('0') << tempTm.tm_mon + 1 << "-" << setw(2) << setfill('0') << tempTm.tm_mday;
outputDate.push_back(oss.str());
} else {
cout << "Year out of range" << endl;
}
}
}
}
return outputDate;
}
};
int main() {
int datesCount;
cin >> datesCount;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
vector<string> dates;
for (int i = 0; i < datesCount; ++i) {
string date;
getline(cin, date);
dates.push_back(date);
}
vector<string> result = Result::reformatDate(dates);
for (const string& formattedDate : result) {
cout << formattedDate << endl;
}
return 0;
}
Goldman Sachs โ
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Monotype is hiring Software Engineer Trainee
For 2023/2022 Grads
https://monotype.wd1.myworkdayjobs.com/en-US/Monotype/job/Noida/Software-Engineer-Trainee_R0003166
For 2023/2022 Grads
https://monotype.wd1.myworkdayjobs.com/en-US/Monotype/job/Noida/Software-Engineer-Trainee_R0003166
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Kwikpic AI Solutions hiring Frontend Developer Interns
Batch : 2024 / 2025 / 2026
Tech Stack Preferred: React.js, NextJs
Stipend per month: โน 20K - 25K
Apply : https://tinyurl.com/49yuen9s
Apply as soon as possible !
Batch : 2024 / 2025 / 2026
Tech Stack Preferred: React.js, NextJs
Stipend per month: โน 20K - 25K
Apply : https://tinyurl.com/49yuen9s
Apply as soon as possible !
cuvette.tech
Frontend Developer Internship in Kwikpic AI Solutions at Mumbai, Maharashtra, India | Cuvette
Apply For Frontend Developer Internship | Skills required are NextJs, React.js | Stipend โน20K-25K | Job Offer โน 6 LPA - 8 LPA | FULL-TIME INTERNSHIP | Location is Work from Home
int minCostToReachDestination(int N, vector<int>& A) {
vector<int> dp(N + 1, INT_MAX);
dp[1] = 0;
for (int i = 1; i <= N; i++) {
if (i + 1 <= N) {
dp[i + 1] = min(dp[i + 1], dp[i] + abs(A[i] - A[i - 1]));
}
if (i + 3 <= N) {
dp[i + 3] = min(dp[i + 3], dp[i] + abs(A[i + 2] - A[i - 1]));
}
}
return dp[N];
}
Amazon ML โ
vector<int> dp(N + 1, INT_MAX);
dp[1] = 0;
for (int i = 1; i <= N; i++) {
if (i + 1 <= N) {
dp[i + 1] = min(dp[i + 1], dp[i] + abs(A[i] - A[i - 1]));
}
if (i + 3 <= N) {
dp[i + 3] = min(dp[i + 3], dp[i] + abs(A[i + 2] - A[i - 1]));
}
}
return dp[N];
}
Amazon ML โ
โค1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
int minCostToReachDestination(int N, vector<int>& A) { vector<int> dp(N + 1, INT_MAX); dp[1] = 0; for (int i = 1; i <= N; i++) { if (i + 1 <= N) { dp[i + 1] = min(dp[i + 1], dp[i] + abs(A[i] - A[i - 1])); โฆ
All passed
Python 3โ
Amazon ML
Amazon ML
๐ข3
int countOccurrences(string parent, string sub) {
transform(parent.begin(), parent.end(), parent.begin(), ::tolower);
transform(sub.begin(), sub.end(), sub.begin(), ::tolower);
int count = 0;
size_t pos = parent.find(sub);
while (pos != string::npos) {
count++;
pos = parent.find(sub, pos + 1);
}
return count;
}
Citi bank โ
transform(parent.begin(), parent.end(), parent.begin(), ::tolower);
transform(sub.begin(), sub.end(), sub.begin(), ::tolower);
int count = 0;
size_t pos = parent.find(sub);
while (pos != string::npos) {
count++;
pos = parent.find(sub, pos + 1);
}
return count;
}
Citi bank โ
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Mondelez International is hiring through Hackathon
For 2022/2023 Grads
Apply fast :
https://tinyurl.com/umd42w4f
For 2022/2023 Grads
Apply fast :
https://tinyurl.com/umd42w4f
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
def gameWinner(colors):
currPlayer = "wendy"
prevPlayer = ""
winner = ""
while True:
moveMade = False
if currPlayer == "wendy":
whiteIndex = colors.find("www")
if whiteIndex = -1:
# 3 consecutive whites found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(whiteIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "bob"
else:
blackIndex = colors.find("bbb")
if blackIndex != -1:
# 3 consecutive blacks found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(blackIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "wendy"
# if no moves possible break
if not moveMade:
winner = prevPlayer
break
return winner
print(gameWinner("wwwbb"))
Python 3โ
Game Winner
JP Morgan
currPlayer = "wendy"
prevPlayer = ""
winner = ""
while True:
moveMade = False
if currPlayer == "wendy":
whiteIndex = colors.find("www")
if whiteIndex = -1:
# 3 consecutive whites found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(whiteIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "bob"
else:
blackIndex = colors.find("bbb")
if blackIndex != -1:
# 3 consecutive blacks found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(blackIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "wendy"
# if no moves possible break
if not moveMade:
winner = prevPlayer
break
return winner
print(gameWinner("wwwbb"))
Python 3โ
Game Winner
JP Morgan