Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to develop a code for deleting duplicate value of an array from right left?

how to develop a code for deleting duplicate value of an array from right left?

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresperformancehelptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 12180691
    wrote on last edited by
    #1

    i had already developed the program but it's not working properly. i am having some confusion on array memory manegment and array arrangement so please do help me to develop this program... Thank you

    L D 2 Replies Last reply
    0
    • U User 12180691

      i had already developed the program but it's not working properly. i am having some confusion on array memory manegment and array arrangement so please do help me to develop this program... Thank you

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You first need to show us the code that is not working, and explain where the problem is.

      1 Reply Last reply
      0
      • U User 12180691

        i had already developed the program but it's not working properly. i am having some confusion on array memory manegment and array arrangement so please do help me to develop this program... Thank you

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        First ask yourself: what constitutes a duplicate value? Instead of going straight to the keyboard to solve this problem, sit at the table with a deck of cards. Ignoring the suits, lay all (or a portion) of the cards out in front of you. Now working from right to left, work through each card and see if it qualifies as a duplicate per your answer from above. This might look something like:

        Compare card 52 to card 51. If they match, remove card 52 from array.
        Compare card 51 to card 50. If they match, remove card 51 from array.
        Compare card 50 to card 49. If they match, remove card 50 from array.
        ...
        Compare card 1 to card 0. If they match, remove card 1 from array.

        An alternative would be if the card is unique, move it to a separate array. Now you can destroy the original array and be left with an array of just unique items. There are other ways to skin this cat, but it's really going to boil down to what makes the most sense to you. You might not initially have the most elegant or efficient solution as others on this board could come up with, but those skills come in time.

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups