Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help in the C language. It's the only language I know at this point and it's the language that the assignment is in.

I need help in the C language. It's the only language I know at this point and it's the language that the assignment is in. Please do not answer in any other language.

I need help finding out why I'm failing a test case in the following problem. I pass the first 22 of 30 test cases but I fail on the 23rd test case. I have no acces to what the test cases are. All I have to go on are two sample test cases.

image text in transcribed

This is my code,

#include int main(){ int temp_num; int index = 0; int temp_num_2 = 0; int size; scanf("%d", &size); int outcome[size]; int temp_1[size]; int temp_2[size]; for(int i = 0; i temp_1[k + 1]){ temp_num = temp_1[k]; temp_1[k] = temp_1[k + 1]; temp_1[k + 1] = temp_num; } } } for(int m = 0; m

Yeah, it's not pretty. I take in the size of the array. Then I scanf the array and copy the array because I will later sort the array, but I will also need to know the indices of the orginal array. I then iterate through the sorted array to find any ints that only appear once in the array and save those ints in a new array. Since everything is already in ascending order I know that the highest value unique int is located at temp_2[temp_num_2 - 1]. I then find where that number is in the original array. I add 1 to the index value because (based on the example test case) they index starting at 1 instead of 0.

Could someone please help me?

P.S. I did go back through and indent my code but apparently it won't post indented.

Input The first line of the input contains one integer n, 1 <>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sql All In One For Dummies 7 Books In One

Authors: Allen G Taylor ,Richard Blum

4th Edition

1394242298, 978-1394242290

More Books

Students also viewed these Databases questions

Question

LOQ 13-9: How can group interaction enable group polarization?

Answered: 1 week ago

Question

6. Identify seven types of hidden histories.

Answered: 1 week ago

Question

What is the relationship between humans and nature?

Answered: 1 week ago