We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a9b9f5f commit 5b8f393Copy full SHA for 5b8f393
1 file changed
LeetCode/uniqueBString.java
@@ -0,0 +1,28 @@
1
+class Solution {
2
+ public String findDifferentBinaryString(String[] nums) {
3
+
4
+ int len=nums[0].length();
5
+ String ans="",ans1="";
6
+ for(int i=0;i<=Math.pow(2,len)-1;i++)
7
+ {
8
+ ans=Integer.toBinaryString(i); //converting to binary sting equivalent to number
9
+ int l=ans.length();
10
+ int a=len-l;
11
+ if(a>0)
12
+ ans1=String.format( "%0" +a+ "d%s" , 0, ans); //adding zeros before the conferted string
13
+ else
14
+ ans1=ans;
15
+ int cnt=0;
16
+ for(int j=0;j<len;j++)
17
18
+ if(!nums[j].equals(ans1)) //checking if the string is present in array or not
19
+ cnt++;
20
+ }
21
+ if(cnt==len) //checking condition and returning the answer
22
+ return ans1;
23
24
25
26
27
28
+}
0 commit comments