loverBoUy's blog

By loverBoUy, history, 21 month(s) ago, In English

Ik this is not the right community to raise this question but many of you guys must have given google technicaL or oa rounds.

Can you share some problem from your oa rounds or technical rounds? It would be a great help for me and for others peeps who are preparing for interviews. TIA!

please do not downvote this!

Full text and comments »

  • Vote: I like it
  • -24
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

In today's kickstart C problem of Round H, my approach was:

a) IN one dfs func, find the number of nodes in the subtree which is strictly lesser than the node. b) in anohter dfs func, find the number of nodes which are strictly greater than the node parent and if a[node]>a[parent] add answer of parent into node. c)combine both and find ans;

code:

Your code here...

void dfs(int node)
{

     vis[node] = true;

     for (auto it : g[node])
     {
          if (vis[it] == false)
          {
               dfs(it);
               if (a[it] < a[node])
                    niche[node] += niche[it] + 1;
          }
     }
     return;
}
void dfs2(int node, int par)
{
     vis[node] = true;
     if (par != -1)
     {
          if (a[node] > a[par])
          {
               upar[node] = upar[par] + 1;

               upar[node] += niche[par];
          }
     }

     for (auto it : g[node])
     {
          if (vis[it] == false)
          {
               dfs2(it, node);
          }
     }
     return;
}
// in main function 
 for (int i = 0; i < n; i++)
     {
          if (ans < upar[i] + niche[i] + 1)
          {
               ans = upar[i] + niche[i] + 1;
               
          }
     }

why is this wrong?

Full text and comments »

  • Vote: I like it
  • -13
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

how to find pth factor of number n; example- n= 12 ,p= 3 factor of 12={1,2,3,4,6,12}; ans= 3;

constraints; n<=10^15; got tle in O(sqrt(n)); pls help

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

Given an array. find the number of subsegments in which you can divide an array such that in the sum array of every subsegment, no two adjacent elements have the same parity;

see the test case for better understanding;

given array= [1 2 2 1] subsegment = ~~~~~ [[1],[2,2],[1]] = [[1],[4],[1]] ~~~~~

valid ,

 [[1,2,2,1]]  = [6] valid,

[[1],[2,2,1]]= [[1],[5]] not valid

hence answer is 2.

please share your approach.

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

Find the mex of the array in o(n) time and constant space complexity; mex = smallest missing element from the array please share your ideas on this tia

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

Statement: You've given a tree of N (1<=N<=1e5) nodes with the root at 1. Each node is initially healthy except the root node. You're given q (1<=q<=1e5) queries and each query is of 2 types. For each query of type 2, store the answers and return the final answer vector.

Type 1: You're given node v, make it unhealthy. Type 2: You're given node v, find the nearest unhealthy node from v. Distance is calculated as the number of edges between the current node v and the nearest unhealthy node.

Please share your optimized logic.

TIA

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

As I didn't find any blog regarding this. Let's discuss our approach here :)

Question A) Simple but tricky.

Question B) I used binary search on multiset to find the largest number <=2*ri.

Question C) My logic was to find the minimum index I (0<= I <=n) such that both sides should be a palindrome.

Question D) I thought to use some brute force and don't know why it passed partially.

Your approach will be welcome in the comment box. Thank you

POV: Why are you guys downvoting this blog? Why there is so much unnecessary hate? This blog helps people to get logic from their superior and some random guys just downvoting this blog. illogical

Full text and comments »

  • Vote: I like it
  • +21
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

Sorry, I don't have any friends (I have a girlfriend but she has no idea about this(:) with whom I can discuss this, so I'm writing this here. I want to announce that I've finally reached pupil after 5 contests.

Thank you

PS: I'll try my best to reach specialists in the next two contests.

Full text and comments »

  • Vote: I like it
  • +71
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

Though I'm not getting any past experience on Schrodinger interview for a summer intern. I'm writing this blog to let people share their experiences.

PS: Please also share past year's problems if you get from somewhere. TIA

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

like say array=[2,3,4,5,6] and query are two types= [1, update,index,val],[2, l,r,val];

for each query of type two , find the number of elements greater than k and for query of type 1 update value of a[index] = val;

please provide code for that

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

There was a question on codeforces similar to the given below statement. Can anyone give me the link or tell me how to solve this?

There are N cities in a country, and all of them are connected by M roads. The country council is planning a roadshow to visit all the N cities, and have asked you to organise it. **** There is a fee E_i to host the show on each i_th road, and the total cost of roadshow is defined as the bitwise OR of all road fees in the itinerary plan. The council has specifically asked that there be no cycles in the final itinerary plan. **** Find the minimum possible cost of roadshow in the country.

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

Can someone pls tell me , why i'm getting 40 instead of 42 in given tc code

Full text and comments »

  • Vote: I like it
  • -13
  • Vote: I do not like it

By loverBoUy, history, 2 years ago, In English

Given a string of 1’s and 2’s, standing at index ‘i’, you can move exactly two steps forward or backward if s[i]==2 , else you can move one step forward or backward if s[i] ==1. A string is called a good string if you can reach the end of the string by moving every index exactly once.

Now, you have been given two Strings A and B (not necessarily good), you have to return the number of possible sub-sequences of swaps available, such that both the strings become good.

Swap means you can swap A[i] with B[i].

Example:

A = 2211 B = 1111 ans = 8

please share your thought! UPD: N<=10^3

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it

By loverBoUy, history, 3 years ago, In English

I'm looking for this course database management system from scratchhttps://www.udemy.com/course/database-management-systems/ I know cf is not the correct platform to ask this question but I thought many of here are b.tech students so they might have this.

it will he great help If you could share the download link

tIA

Full text and comments »

  • Vote: I like it
  • -23
  • Vote: I do not like it

By loverBoUy, history, 3 years ago, In English

I have tried this question — RBG construction cook-off problem. But, getting wrong answer. Please, someone tell me where is mistake, code TIA!

Full text and comments »

  • Vote: I like it
  • -9
  • Vote: I do not like it

By loverBoUy, history, 3 years ago, In English

Hey folks!

Why most of the coders are usually inspired by an anime character?

If you wanna choose the anime that inspired you, then who it will be?

My all-time fav. is G.O.A.T Naruto UZUMAKI and yours?

Full text and comments »

  • Vote: I like it
  • -16
  • Vote: I do not like it

By loverBoUy, history, 3 years ago, In English

hey folks!

Don't downvote it!

Can anyone tell me, how can I earn my pocket money through online stuff?

I'm a noob in developing like to do cc stuff. TIA!

Full text and comments »

  • Vote: I like it
  • -30
  • Vote: I do not like it

By loverBoUy, history, 3 years ago, In English
  • Vote: I like it
  • -3
  • Vote: I do not like it

By loverBoUy, history, 3 years ago, In English

Hello!

Given a binary tree, find a** maximum path for each node**.

Hope to get an optimal solution Input- N=6

edges= 1->2,2->3,1->4,4->5,4->6

output= 2 3 4 3 4 4

Thanks in advance!

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it