Блог пользователя loverBoUy

Автор loverBoUy, история, 14 месяцев назад, По-английски

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!

Полный текст и комментарии »

  • Проголосовать: нравится
  • -24
  • Проголосовать: не нравится

Автор loverBoUy, история, 17 месяцев назад, По-английски

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?

Полный текст и комментарии »

  • Проголосовать: нравится
  • -13
  • Проголосовать: не нравится

Автор loverBoUy, история, 18 месяцев назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор loverBoUy, история, 19 месяцев назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

Автор loverBoUy, история, 19 месяцев назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

Автор loverBoUy, история, 20 месяцев назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор loverBoUy, история, 20 месяцев назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • +21
  • Проголосовать: не нравится

Автор loverBoUy, история, 20 месяцев назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +71
  • Проголосовать: не нравится

Автор loverBoUy, история, 21 месяц назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор loverBoUy, история, 21 месяц назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор loverBoUy, история, 21 месяц назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор loverBoUy, история, 21 месяц назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • -13
  • Проголосовать: не нравится

Автор loverBoUy, история, 21 месяц назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • -4
  • Проголосовать: не нравится

Автор loverBoUy, история, 2 года назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • -23
  • Проголосовать: не нравится

Автор loverBoUy, история, 2 года назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • -9
  • Проголосовать: не нравится

Автор loverBoUy, история, 2 года назад, По-английски

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?

Полный текст и комментарии »

  • Проголосовать: нравится
  • -16
  • Проголосовать: не нравится

Автор loverBoUy, история, 2 года назад, По-английски

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!

Полный текст и комментарии »

  • Проголосовать: нравится
  • -30
  • Проголосовать: не нравится

Автор loverBoUy, история, 2 года назад, По-английски
  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

Автор loverBoUy, история, 2 года назад, По-английски

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!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится