Write, efficient code for extracting unique elements from
a sorted list of array.
e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).
Answer Posted / sam
private int[] GetUniqueList(int[] A)
{
if(A == null ) return null;
List<int> result = new List<int>();
for(int i=0;i<A.Length-1;i++)
{
if (A[i] != A[i + 1]) result.Add(A[i]);
}
if(A.Length>0)
result.Add(A[A.Length-1]);
return result.ToArray();
}
Is This Answer Correct ? | 0 Yes | 6 No |
Post New Answer View All Answers
how to test pierrot divisor
Write a routine to implement the polymarker function
Sir... please give some important coding questions asked by product companies..
write a c program to input initial & final time in the format hh:mm and find the time intervel between them? Ex inputs are initial 06:30 final 00:05 and 23:22 final 22.30
Develop a routine to reflect an object about an arbitrarily selected plane
Design an implement of the inputs functions for event mode
Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??
To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']
How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?
why nlogn is the lower limit of any sort algorithm?
#include
can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail
write a program for area of circumference of shapes
why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?
What is data _null_? ,Explain with code when u need to use it in data step programming ?