16,004,571 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Zeeshan Ahmad Jul2022 (Top 8 by date)
Zeeshan Ahmad Jul2022
30-Jul-22 1:54am
View
Okay thank you. I will definitely try it.
Zeeshan Ahmad Jul2022
29-Jul-22 15:25pm
View
Done
Zeeshan Ahmad Jul2022
29-Jul-22 15:20pm
View
It is actually in my assignment. I can get you the info
You have been given a random integer array/list(ARR) and a number X. Find and return the triplet(s) in the array/list which sum to X.
Note :
Given array/list can contain duplicate elements.
Input format :
The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow.
First line of each test case or query contains an integer 'N' representing the size of the first array/list.
Second line contains 'N' single space separated integers representing the elements in the array/list.
Third line contains an integer 'X'.
Output format :
For each test case, print the total number of triplets present in the array/list.
Output for every test case will be printed in a separate line.
Constraints :
1 <= t <= 10^2
0 <= N <= 10^3
0 <= X <= 10^9
Sample Input 1:
7 Size
1 2 3 4 5 6 7
12
Sample Output 1:
5
Sample Input 2:
7 Size
1 2 3 4 5 6 7
19
Sample Output 2:
0
Explanation for Input 2:
Since there doesn't exist any triplet with sum equal to 19 for the first query, we print 0.
Zeeshan Ahmad Jul2022
28-Jul-22 17:18pm
View
Done
Zeeshan Ahmad Jul2022
28-Jul-22 16:57pm
View
That's fine
Zeeshan Ahmad Jul2022
28-Jul-22 16:57pm
View
public class TimeAndSpaceComplexity_DuplicateInArray {
public static int findDuplicate(int[] arr) {
int n = arr.length-2;
int sum = 0;
for(int i : arr){
sum+=i;
}
return (sum - ((n*(n+1))/2));
}
}
This one works fine but I don't understand how
Zeeshan Ahmad Jul2022
28-Jul-22 16:45pm
View
Deleted
You have been given an integer array/list(ARR) of size N which contains numbers from 0 to (N - 2). Each number is present at least once. That is, if N = 5, the array/list constitutes values ranging from 0 to 3, and among these, there is a single integer value that is present twice. You need to find and return that duplicate number present in the array.
Note :
Duplicate number is always present in the given array/list.
Input format :
The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow.
First line of each test case or query contains an integer 'N' representing the size of the array/list.
Second line contains 'N' single space separated integers representing the elements in the array/list.
Output Format :
For each test case, print the duplicate element in the array/list.
Output for every test case will be printed in a separate line.
Constraints :
1 <= t <= 10^2
0 <= N <= 10^6
Time Limit: 1 sec
Sample Input 1:
1
9
0 7 2 5 4 7 1 3 6
Sample Output 1:
7
Sample Input 2:
2
5
0 2 1 3 1
7
0 3 1 5 4 3 2
Sample Output 2:
1
3
My teacher said the the code provided would work and it does but I can't make sense of it.
Zeeshan Ahmad Jul2022
28-Jul-22 16:41pm
View
It's supposed to give me the repeated element in a array list and my teacher did it this way. I could not understand how
Show More