โ
โ
โ
HackerRank Count Binary Substrings - Java Code Solution
Code 1-
Code 1-
int getSubstrings(string s) {
int n = s.size();
int count =0, ans=0;
vector<int> groups;
for(int i=0;i<n-1;i++){
if (s[i] !=s[i+1]){
groups.push_back(count+1);
count=0;
}
else{
count++;
}
}
for(int i=0;i<groups.size()-1; i++){
ans += min(groups[i], groups[i+1]);
}
return ans;
}
Code 2 - import java.util.regex.*;
class Solution {
static Pattern p = Pattern.compile("((0(?<=0))+|(1(?<=1))+)");
public int countBinarySubstrings(String s) {
Matcher m = p.matcher(s);
int last = 0;
int cnt = 0;
while (m.find()) {
int now = m.end()-m.start();
cnt += Math.min(last, now);
last = now;
}
return cnt;
}
}
โ
โ
โ
#HackerRank Examination Data - SQL Solution
Select UPPER(Name),Marks from exam
where marks%2=0
order by name;
โ
โ
โ
#HackerEarth Closest to Zero - Java Solutions
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
int curr = 0;
int ans = a[0];
Arrays.sort(a);
for (int i=0; i < a.length; i++){
curr = a[i] * a[i];
if ( curr <= (ans*ans) ) {
ans = a[i];
}
}
System.out.println(ans);
}
}
โ
โ
โ
#Mettl Nth Character in Decrypted String - Python Solutions
def dString(s,n):
result=""
for i in range(len(s)):
if s[i].isdigit():
c=s[i-1]
for j in range(int(s[i])-1):
result+=c
else:
result+=s[i]
if(n-1<len(result)):
return result[n-1]
else:
return -1
n=input("enter string")
m=int(input())
print(dString(n,m))
โ
โ
โ
#HackerRank Amazon Fresh Deliveries - Java Solutions - HackerRank Solutions
import java.util.*;
public class Main
{
public static int[][] closestKLocations(int[][] allLocations, int k) {
PriorityQueue<int[]> pq = new PriorityQueue<>(k+1, new Comparator<int[]>() {
public int compare(int[] a1, int[] a2) {
int x1 = a1[0];
int y1 = a1[1];
int x2 = a2[0];
int y2 = a2[1];
int distance1 = x1*x1 + y1*y1;
int distance2 = x2*x2 + y2*y2;
if (distance1 == distance2) return x2 - x1;
return distance2 - distance1;
}
});
for (int[] location : allLocations) {
pq.add(location);
if (pq.size() > k) pq.poll();
}
int[][] result = new int[k][2];
pq.toArray(result);
return result;
}
public static void main(String[] args) {
int[][] test1 = new int[][] {
{1, 2},
{1, -1},
{3, 4}
};
int[][] result = closestKLocations(test1, 2);
for (int[] each_elt : result) {
System.out.println(String.format("[%d,%d]", each_elt[0], each_elt[1]));
}
}
}
๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ช๐ชimport java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
public class Main {
List<List<Integer>> ClosestXdestinations(int numDestinations, List<List<Integer>> allLocations,
int numDeliveries) {
// CORNER CASE
if (allLocations == null || allLocations.size() == 0 || allLocations.size() < numDeliveries) {
return new ArrayList<>();
}
List<List<Integer>> result = new ArrayList<>();
PriorityQueue<Position> minHeap = new PriorityQueue<>((o1, o2) -> o1.distance - o2.distance);
/*
PART1: add each position into minHeap
*/
for (int i = 0; i < allLocations.size(); i++) {
List<Integer> list = allLocations.get(i);
// Pythagorean Theorem
int distance = list.get(0) * list.get(0) + list.get(1) * list.get(1);
Position p = new Position(list, distance);
minHeap.add(p);
}
/*
PART2: grab the number of numDeliveries from minHeap
*/
for (int i = 0; i < numDestinations && i < numDeliveries; i++) {
result.add(minHeap.poll().list);
}
return result;
}
class Position {
List<Integer> list;
int distance;
public Position(List<Integer> list, int distance) {
this.list = list;
this.distance = distance;
}
}
/*
TEST CASE
*/
public static void main(String[] args) {
Main test = new Main();
int numDestinations = 3;
int numDeliveries = 2;
List<Integer> list1 = new ArrayList<>();
List<Integer> list2 = new ArrayList<>();
List<Integer> list3 = new ArrayList<>();
List<List<Integer>> allLocations = new ArrayList<>();
list1.add(1);
list1.add(2);
list2.add(3);
list2.add(4);
list3.add(1);
list3.add(-1);
allLocations.add(list1);
allLocations.add(list2);
allLocations.add(list3);
List<List<Integer>> result = test.ClosestXdestinations(numDestinations, allLocations, numDeliveries);
for (int i = 0; i < result.size() ; i++) {
System.out.println("[" + result.get(i).get(0) + "," + result.get(i).get(1) + "]");
}
}
}
โ
โ
โ
Uber Sums Divisible By K - C++ Solutions
#include <bits/stdc++.h>
using namespace std;
int sumsDivisibleByK(int A[], int n, int K)
{
int freq[K] = { 0 };
for (int i = 0; i < n; i++)
++freq[A[i] % K];
int sum = freq[0] * (freq[0] - 1) / 2;
for (int i = 1; i <= K / 2 && i != (K - i); i++)
sum += freq[i] * freq[K - i];
if (K % 2 == 0)
sum += (freq[K / 2] * (freq[K / 2] - 1) / 2);
return sum;
}
int main()
{
int A[] = { 1,2,3,4,5 };
int n = sizeof(A) / sizeof(A[0]);
int K = 3;
cout << sumsDivisibleByK(A, n, K);
return 0;
}
โ
โ
โ
#HackerRank Largest Number of Orders - SQL Solutions
select z
from (select x.customer_ID as z,
count(x.customer_ID) as l
from Orders x, Orders y
where x.ID = y.ID
group by x.customer_ID
order by l desc)
where rownum = 1;
โ
โ
โ
#HackerEarth Maximum Similarity - C++ HackerEarth Solutions
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
string str1, str2;
cin>>str1>>str2;
map<char,int> mp2;
for(int i=0;i<str2.size();i++)
mp2[str2[i]]++;
int result=0;
for(int i=0;i<str1.size();i++)
{
if(mp2[str1[i]]>0)
{
result++;
mp2[str1[i]]--;
}
else
break;
}
cout<<result<<endl;
}
return 0;
}
โค1
โ
โ
โ
#HackerRank Metro Land Festival - C++ HackerRank Solution
int cost(x, y, a, b) {
return (abs(x-a)+abs(y-b));
}
int minimizeCost(vector<int> numpeople, vector<int> x, vector<int> y){
vector<int> xx, yy;
int ans = 0;
for(int i = 0 ; i < numpeople.size();i++){
int count = numpeople[i];
while(count--){
xx.push_back(x[i]);
yy.push_back(y[i]);
}
}
sort(xx.begin(), xx.end());
sort(yy.begin(), yy.end());
int mx, my;
mx = xx[xx.size() / 2];
my = yy[yy.size() / 2];
for(int i = 0; i < numpeople.size(); i++){
ans += numpeople[i] * cost(mx, my, x[i], y[i]);
}
return ans;
}
๐2
โ
โ
โ
#HackerRank Highly Profitable Months - HackerRank C++ Solutions
int countHighlyProfitableMonths(vector<int> stockPrices,int k){
int n=stockPrices.size(),count=1;
vector<int> a;
for(int i=0;i+1<n;i++){
if(stockPrices[i+1]>stockPrices[i])
count+=1;
else{
a.push_back(count);
count=1;
}
}
a.push_back(count);
int ans=0;
for(auto x:a){
if(x>=k)
ans+=(x-k+1);
}
return ans;
}
โ
โ
โ
#HackerEarth Coin collector - C++ HackerEarth Solutions
#include<bits/stdc++.h>
using namespace std;
long long solve (int N, vector<long long> A, int X) {
vector<long long>dp(N);
long long best_odd_score, best_even_score;
if (A[0] % 2 == 0)
best_even_score = A[0], best_odd_score = -X;
else
best_odd_score = A[0], best_even_score = -X;
for (int i = 1; i < N; i++)
{
if (A[i] % 2)
{
dp[i] = max(best_odd_score + A[i], best_even_score - X + A[i]);
best_odd_score = max(best_odd_score, dp[i]);
}
else
{
dp[i] = max(best_even_score + A[i], best_odd_score - X + A[i]);
best_even_score = max(best_even_score, dp[i]);
}
}
return dp[N - 1];
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int T;
cin >> T;
for (int t_i = 0; t_i < T; t_i++)
{
int N;
cin >> N;
vector<long long> A(N);
for (int i_A = 0; i_A < N; i_A++)
{
cin >> A[i_A];
}
int X;
cin >> X;
long long out_;
out_ = solve(N, A, X);
cout << out_;
cout << "\n";
}
}
๐ ReNew Power Off Campus Drive 2022 : Hiring Freshers as Graduate Engineer Trainees With 6 LPA
* Job Role : Graduate Engineer Trainees
* Qualification : B.E/ B.Tech
* Experience : Freshers
* CTC : 5 โ 6 LPA
https://fresherearth.blogspot.com/2022/03/ReNew-Power-Off-Campus-Drive-2022-Hiring-Freshers-as-Graduate-Engineer-Trainees-With-6-LPA.html
* Job Role : Graduate Engineer Trainees
* Qualification : B.E/ B.Tech
* Experience : Freshers
* CTC : 5 โ 6 LPA
https://fresherearth.blogspot.com/2022/03/ReNew-Power-Off-Campus-Drive-2022-Hiring-Freshers-as-Graduate-Engineer-Trainees-With-6-LPA.html
FresherEarth - Get All Latest Jobs Here
ReNew Power Off Campus Drive 2022 : Hiring Freshers as Graduate Engineer Trainees With 6 LPA
fresher jobs, freshers jobs, off campus jobs, latest fresher jobs, fresher jobs bangalore, fresher jobs hyderabad, latest walk in drive
๐Cognizant Group Discussion Topics:
1)Fast food culture
2)Covid 19
3)Ukraine russia war
4)Women empowerment
5)Digital india
1)Fast food culture
2)Covid 19
3)Ukraine russia war
4)Women empowerment
5)Digital india
๐ WIPRO INTERVIEW EXPERIENCE(Mechanical)
1- why you want to join wipro as a mechanical background
2- what is cloud computing
3- what is machine learning
4- what is diff between C ++ and C
5- what is encapsulation
6- what is deep learning
7- What is algorithm of determine Prime No.
8- what is torque
9- what is your challenges
10- what is your achievement
11- do you able to relocate
12- what is 10,12,btech percentage
13-introduction
14- what programming languages you know
1- why you want to join wipro as a mechanical background
2- what is cloud computing
3- what is machine learning
4- what is diff between C ++ and C
5- what is encapsulation
6- what is deep learning
7- What is algorithm of determine Prime No.
8- what is torque
9- what is your challenges
10- what is your achievement
11- do you able to relocate
12- what is 10,12,btech percentage
13-introduction
14- what programming languages you know
๐ Infosys Off Campus Drive | Systems Engineer | 3.6 LPA
* Job Role : Systems Engineer
* Education : BE/BTech/ME/MTech/MCA/MSc
* Batch : 2019/2020/2021/2022
* CTC : 3.6 LPA
https://fresherearth.blogspot.com/2022/03/Infosys-Off-Campus-Drive-Systems-Engineer-3.6-LPA.html
* Job Role : Systems Engineer
* Education : BE/BTech/ME/MTech/MCA/MSc
* Batch : 2019/2020/2021/2022
* CTC : 3.6 LPA
https://fresherearth.blogspot.com/2022/03/Infosys-Off-Campus-Drive-Systems-Engineer-3.6-LPA.html
FresherEarth - Get All Latest Jobs Here
Infosys Off Campus Drive | Systems Engineer | 3.6 LPA
fresher jobs, freshers jobs, off campus jobs, latest fresher jobs, fresher jobs bangalore, fresher jobs hyderabad, latest walk in drive
๐Accenture Associate Software Engineer Hiring | 4.5 LPA
Job Role: Associate Software Engineer
Qualification: BE/BTech/BCA/B.Com/BSc/BBA/BA
Year Of Passing: 2019/2020/2021/2022
Experience: Freshers
Location : Bangalore, Hyderabad, Chennai, Pune
Salary : 4.5 LPA
https://fresherearth.blogspot.com/2022/03/Accenture-Associate-Software-Engineer-Hiring-4.5-LPA.html
Job Role: Associate Software Engineer
Qualification: BE/BTech/BCA/B.Com/BSc/BBA/BA
Year Of Passing: 2019/2020/2021/2022
Experience: Freshers
Location : Bangalore, Hyderabad, Chennai, Pune
Salary : 4.5 LPA
https://fresherearth.blogspot.com/2022/03/Accenture-Associate-Software-Engineer-Hiring-4.5-LPA.html
FresherEarth - Get All Latest Jobs Here
Accenture Associate Software Engineer Hiring | 4.5 LPA
fresher jobs, freshers jobs, off campus jobs, latest fresher jobs, fresher jobs bangalore, fresher jobs hyderabad, latest walk in drive
#interviewhacks
โ Donโt confuse a job interview with a job offer
โ Avoid trashing your previous jobs
โ Research the company in advance
โ Mind your body language
โ Donโt expect an offer right away
โ Donโt confuse a job interview with a job offer
โ Avoid trashing your previous jobs
โ Research the company in advance
โ Mind your body language
โ Donโt expect an offer right away
C++โ
(IBM)