SlaveCode.
1. Two Sum
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.
Example 1
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
// Because nums[0] + nums[1] = 9
Example 2
Input: nums = [3,2,4], target = 6
Output: [1,2]
// Because nums[1] + nums[2] = 6
Constraints
2 <= nums.length <= 104-109 <= nums[i] <= 109-109 <= target <= 109Only one valid answer exists.
1 class Solution {
2 public int[] twoSum(int[] nums, int target) {
3 HashMap<Integer, Integer> map = new HashMap<>();
4
5 for (int i = 0; i < nums.length; i++) {
6 int complement = target - nums[i];
7
8 if (map.containsKey(complement)) {
9 return new int[] { map.get(complement), i };
10 }
11
12 map.put(nums[i], i);
13 }
14
15 return new int[] {};
16 }
17}Everything you need to compete and grow.
A unified platform built around the developer's journey — from your first algorithm to your first arena win.
Your journey, quantified in real-time.
SlaveCode tracks every line you write and every battle you win to build your global developer identity.
XYZ XYZ
xyz11
Rank
3,14,914
2 mins ago
14 mins ago
45 mins ago
1 hour ago
2 hours ago
Network
Social Activity
1220/3191
4 Attempting
408/850
692/1621
120/720
Arena Records
Match History
Median of Two Sorted Arrays
Longest Palindrome
Two Sum
Median of Two Sorted Arrays
Longest Palindromic Substring
1,242submissions in the past one year
Define the Battlefield
Orchestrate competitive environments at scale. Whether hosting a private 1v1 duel or a 50-player tournament, our engine handles the orchestration while you define the difficulty, language constraints, and problem topics.
Arena Lobby
Maximum Sum Path Challenge
Participants
4 / 50Real-time Synchronization
A unified command center for hosts and players. Monitor participant presence in real-time, adjust match parameters on the fly, and ensure every challenger is optimized for the battle ahead.
1class Solution {
2 public int[] twoSum(int[] nums, int target) {
3 HashMap<Integer, Integer> map = new HashMap<>();
4
5 for (int i = 0; i < nums.length; i++) {
6 int complement = target - nums[i];
7 if (map.containsKey(complement)) {
8 return new int[] { map.get(complement), i };
9 }
10 map.put(nums[i], i);
11 }
12 return new int[] {};
13 }
14}Optimized Performance
High-stakes coding without the latency. A dual-pane IDE synchronized with the arena server, featuring instant test feedback and a head-to-head submission tracker.
| Rank | Player | Score | Verdict |
|---|---|---|---|
1 | John Carterjohncarter | 120 | Accepted |
2 | Alicia Brownaliciab | 80 | Accepted |
3 | Ravi Vermaraviv | 50 | System Error |
4 | Sharukh Khansharukhkhan | 20 | System Error |
Post-Mortem Analytics
A technical breakdown of every competitive encounter. Analyze rankings, compare solution logic, and review granular performance metrics across the field.
1fn main() {
2 let a = 25;
3 let b = 17;
4
5 println!("Calculating sum...");
6 println!("Sum of {} + {} is: {}", a, b, a + b);
7}Compiler Output
Calculating sum...
Sum of 25 + 17 is: 42
Compiler Playground
A high-performance sandbox where you can code and test logic in multiple languages. Execute your scripts instantly in a distraction-free environment.
Ready to enter the arena?
Join thousands of developers competing, growing, and proving their skills every day. Your rank is waiting.
Free forever · No credit card required · Instant access