Rishi_Kant's blog

By Rishi_Kant, history, 4 years ago, In English

Please help me in B. Here is my solution 88615363. My approach

  1. I create two variables c and d to count number of 1 and -1 in list a from index[0,n-1]. I didn't take the last index as it can't be i, it only can be j as i < j.

  2. I check if a[0] is equal to b[0]. if not just print NO.

  3. Now go in else block. I used a loop from last index to 1. Now check if a[i] == b[i] then just check if a[i-1] is 1 then remove count of c by 1 and if a[i-1] is -1 then remove count of d by 1.

  4. Else if a[i] < b[i] then check count of c. If it is greater then 0 remove count by 1 else break and if a[i] > b[i] Just check then check count of d. Please tell me where I did wrong. Thanku

Full text and comments »

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

By Rishi_Kant, history, 4 years ago, In English

Hi everyone, I am getting WA in codechef lunchtime priblem INCRDEC INCRDEC my code for this is code.

My approach

1.Firstly, I checked that elements of given array are unique or not if unique I print YES and print array in sorted order.

2.If its not unique, I create a Map and update it on encounter frequency more then one and append that element in a new list.

3.I sorted the hashmap and check about the max key, if value of max(key) is greater then 1 print NO.

4.Same I checked the values of rest keys if values are greater then 2 I took a variable, initialize it by 0 and update it to 1.

5.Finally I check if variable if 0 print YES and reversely sort the list which I create in map and marge it with set.

please help me in finding my fault, please provide any testcase where my code going wrong. Thanks alot.

Full text and comments »

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

By Rishi_Kant, history, 5 years ago, In English

Please tell me where I am wrong. 84020290

Full text and comments »

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