Old discuss is read-only now. Please go to New LeetCode Discuss for your questions and answers!

User account in old discuss will not integrate to the new one, but new discuss is integrated with new online judge, which means, if you already have an account in new online judge, you can access new discuss immediately!

If you want to ask for question relevant to the posts in old discuss, please copy content as part of your question, only old discuss link is NOT ALLOWED!

Please read the FAQ in new LeetCode Discuss to help yourself making the best use of Discuss!

Given an array A = [2, 6, -1, 8, 0] and an operation called flip which runs in O(1) in hypothetical machine.

sort the array.

flip operation for array A = [2, 6, -1, 8, 0] A.flip(0)=[0, 8, -1, 6, 2] A.flip(3)=[2, 6, -1, 0, 8] A.flip(2)=[2, 6, 0, 8, -1]

try doing in O(nlogn), Please let me know if question is not clear.

asked 06 Jan, 15:04

Gautam%20Goswami's gravatar image

Gautam Goswami
9133
accept rate: 0%

edited 09 Jan, 02:40

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • Indent code by 4 spaces.
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×6
×4
×3
×2

Asked: 06 Jan, 15:04

Seen: 88 times

Last updated: 09 Jan, 02:40