From 8734b309d82801107abfd2e205eb5f9ac1bc6206 Mon Sep 17 00:00:00 2001 From: Meghanamaturi <88201712+Meghanamaturi@users.noreply.github.com> Date: Tue, 4 Oct 2022 20:38:43 +0530 Subject: [PATCH] Created Remove Duplicates from Sorted Array This file consists of java code for leetcode easy problem #24 Remove Duplicates from Sorted Array --- .../Easy/Remove Duplicates from Sorted Array | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Algorithms/Easy/Remove Duplicates from Sorted Array diff --git a/Algorithms/Easy/Remove Duplicates from Sorted Array b/Algorithms/Easy/Remove Duplicates from Sorted Array new file mode 100644 index 0000000..1d76b22 --- /dev/null +++ b/Algorithms/Easy/Remove Duplicates from Sorted Array @@ -0,0 +1,27 @@ +class Solution { + public int removeDuplicates(int[] nums) { + int x = nums.length; + int i,j,k,z=0,m=0; + for( i =0; i< x;i++) + { + k = nums[i]; + if(nums[i]!= 2147483647){ + for( j = i+1; j < x; j++ ){ + + if(k == nums[j]) { + nums[j] = 2147483647; + } + } + } + } + for(int y =0;y