meesho on campus 3 dsa questions
1Q there is string s given k u can shift k elements from stat to back any number of times and given for formula sum of (N-i)pos[s[i]] should be minimum . n value is 1000 so n^2 sol is valued i have done it .
2Q give array of size n . if arr[i] = 2 we need to count no of numbers of size arr[i] whose sum of digits is 4k+1 k can be positive number. the range of arr[i] is 1e9. i thoudht its digit dp but i figure it out. i dint do.
3Q given array of population. vector<vector> cities with roads i mean there are n cites . they give quries where quries[i][0] = u quries[i][1] = v, quries[i][2] = w. there are Q no of quries. we need to return vector of size Q. we need to find u to v how many cites populations is atmost w.
i made union by size and parent array i did it. then took quries if parent[u]!=parent[v] then cnt is 0 else here if i use bfs i adds all cities which are of same components but not in part with u and v . so i though of dfs i start with u and go v if i find v then i return 1 and by backtracking add the cites whose paths is btw u and v and population is atmost w. but i coudnt code this.
i solve 650+ problems on leetcode and given 25 contest with 1700+ rating . i feel low as i cant solve the questions. and also the questions language is more confusing . plz guide and tell ans i possible


