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

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

Here I'm doing searching work only.unordered_map<>takes O(1) for searching and map<>takes O(long) for searching so I didn't get that why I'm getting tle. Here is my code link -:

https://codeforces.me/contest/1642/submission/147498144

Above is my tle code.

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

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

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

Here is the brief explanation of my question -:

Given an array of positive and negative numbers, arrange them in an alternate fashion such that every positive number is followed by negative and vice-versa maintaining the order of appearance. Number of positive and negative numbers need not be equal. If there are more positive numbers they appear at the end of the array. If there are more negative numbers, they too appear in the end of the array.

Example: Input: arr[] = {1, 2, 3, -4, -1, 4} Output: arr[] = {-4, 1, -1, 2, 3, 4}

Input: arr[] = {-5, -2, 5, 2, 4, 7, 1, 8, 0, -8} output: arr[] = {-5, 5, -2, 2, -8, 4, 7, 1, 8, 0}

I'm trying to solve this problem with the constraint O(n) time complexity and O(1) space complexity.But I didn't get any logic

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

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

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

Here is the question link which I solved-:https://codeforces.me/contest/1617/problem/A Here is my submission code-:https://codeforces.me/contest/1617/my After going to this link plz go to the latest submission to see my code.

This code works fine in all other IDE (CodeChef,VsCode,Hackerrank) .But when I submit my code on codeforces running contest it gives me errors. Plz, anybody help me out.

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

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