Algorithm: efficient way to remove duplicate integers from an array
来源:互联网 发布:怎么安装python 编辑:程序博客网 时间:2024/05/21 11:18
http://stackoverflow.com/questions/1532819/algorithm-efficient-way-to-remove-duplicate-integers-from-an-array
I got this problem from an interview with Microsoft.
Given an array of random integers, write an algorithm in C that removes duplicated numbers and return the unique numbers in the original array.E.g Input: {4, 8, 4, 1, 1, 2, 9} Output: {4, 8, 1, 2, 9, ?, ?}
One caveat is that the expected algorithm should not required the array to be sorted first. And when an element has been removed, the following elements must be shifted forward as well. Anyway, value of elements at the tail of the array where elements were shifted forward are negligible.
Update: The result must be returned in the original array and helper data structure (e.g. hashtable) should not be used. However, I guess order preservation is not necessary.
Update2: For those who wonder why these impractical constraints, this was an interview question and all these constraints are discussed during the thinking process to see how I can come up with different ideas.
一个大小为N的数组,里面是N个整数,怎样去除重复。
讨论:http://ask.julyedu.com/question/190
- Algorithm: efficient way to remove duplicate integers from an array
- A very efficient and economical way to shift an array
- How to remove Duplicates from an Array
- Given an array of characters which form a sentence of words, give an efficient algorithm to reverse
- Remove duplicate elements in an array
- leetcode之 Remove Duplicate from Sorted Array
- remove duplicate from sort array 2
- LeetCode 26 remove Duplicate from sorted array
- 【Leetcode Algorithm】Remove Duplicates from Sorted Array
- An Efficient Way to Draw Approximate Circles in OpenGL
- Remove an element from Javascript Array
- Find M Integers from an Array of Size N equally
- Algorithm之路二十六:Remove Duplicates from Sorted Array
- An Efficient Digital Search Algorithm by Using a Double-Array Structure笔记
- What is the correct way to completely remove an application?
- Best Way to Loop Through an Array in JavaScript
- Question- Remove empty elements from an array in Javascript
- ELLA:An Efficient LIfelong Learning Algorithm 随笔
- mac平台执行Yii框架的command类
- 2012年5月SAT香港真题解析
- hdu2851 (dp)
- 第30题:在从1到n的整数中1出现的次数
- mysql删除某字段的最后一位
- Algorithm: efficient way to remove duplicate integers from an array
- On the way
- dll库加载所产生的问题
- matlab快速排序
- UITextField, UITextView长度限制
- Java编程规范整理
- 如何配置rhel6,允许让manager连接其图形化界面
- 【回味无穷】ASP.NET内部控件
- Android 开源项目android-open-project个人和组织解析 个人,组织,博客