s = input("Enter a string: ") a = [0] * 255 for i in range(0, len(s), 2): a[ord(s[i])] += int(s[i + 1]) ans = "" for i in range(255): if a[i] != 0: ans += chr(i) ans += str(a[i]) print("Output:", ans)
@malavipande4642
9 ай бұрын
Thanks a million
@KomalSingh-qb3hx
9 ай бұрын
question 1 in java import java.util.*; public class ibm2 { public static void main(String []args){ Scanner sc=new Scanner(System.in); String s=sc.nextLine(); int ch1[]=new int[255]; for(int i=0;i
@ronit712
11 ай бұрын
code for binary to decimal #include using namespace std; int main(){ int binary=111,decimal=0,x=0; while(binary>0){ int rem=binary%10; decimal+=pow(2,x); x++; binary=binary/10; } cout
@ronitsrivastava377
22 күн бұрын
Integer.toBinaryString(64); in Java. C++ has something similar?
@naveen5978
Күн бұрын
Binary to decimal: s = int(input('Enter: ')) res = 0 counter = 0 while s!=0: res += (2**counter)*(s%10) s = s//10 counter+=1 print("Output:", res)
@ayushmaansural4896
Жыл бұрын
Hi Team, I had IBM coding round on 31st of August (ON_Campus) and questions were super huge and complex. Some required concepts from DP too.
@user-ho8gy6lj7l
Жыл бұрын
which clg
@ayushmaansural4896
Жыл бұрын
@@user-ho8gy6lj7l Tier 3 college of Kolkata-
@MARIAM-eb9zw
7 күн бұрын
Can you please share the questions ?
@echelon7zulu
5 сағат бұрын
Was the exam proctored? Can we refer syntax
@naveen5978
Күн бұрын
s = input("Enter: ") chk_array = [0]*255 res = "" for i in range(1,len(s),2): chk_array[ord(s[i-1])] += int(s[i]) for i in range(len(chk_array)): for j in range(chk_array[i]): res += chr(i) print(res)
@akashroy4467
7 ай бұрын
For 1st question we can use this solution : import Foundation var mainArr = ["g","2","b","4","a","2","c","5","a","1","Z","7","A","4"] var ansArr = [String]() for var i in 0..0 { ansArr.append(name) ansArr.append(String(count)) } } print("Hi:",ansArr ) print("Hello World")
@ankitpundhir9863
9 ай бұрын
What if the frequency is given in more than 1 digit? Like a5g14c6b1a12b3
@akashpatil1676
9 ай бұрын
Good question bhai👍
@DeveloperRB
4 күн бұрын
we have to parse the value like: char key = s[i]; // The character key i++; // Move to the next character which should be the start of the number // Extract the number which may have multiple digits int value = 0; while (i < s.length() && isdigit(s[i])) { value = value * 10 + (s[i] - '0'); i++; }
@suryaprasadpadhi2525
2 ай бұрын
I gave coding assessment for back-end developer I completed Java but while writing half of the sql my time over... So can I get selected for next English round
@handsome_devil2747
2 ай бұрын
what was the question can u tell i am written today
@echelon7zulu
5 сағат бұрын
Was the exam proctored? Can we refer syntax
@classyclass6379
Жыл бұрын
Thank you sir
@KomalSingh-qb3hx
9 ай бұрын
//program to convert decimal number to binary number import java.util.*; public class ibm3 { public static void main(String []args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int rem=0; StringBuffer sb=new StringBuffer(); while(n>0){ rem=n%2; sb.append(rem); n=n/2; } sb.reverse(); System.out.println(sb); } }
@ritikajain9308
9 ай бұрын
Kya hum javascript me code kr skte hai
@mohammadsheesh
Жыл бұрын
Good morning Sir
@Anshologey
9 ай бұрын
Good Morning
@rohitd09
8 ай бұрын
Python solution using dict: import string st = input('Enter incorrectly compressed string: ') dt = {} for i in st: if i.isalpha(): dt[i] = 0 for i in range(len(st)): if st[i].isalpha(): dt[st[i]] += int(st[i+1]) print(dt) ls_keys = list(dt.keys()) ls_keys.sort() dt_sorted = {i:dt[i] for i in ls_keys} ls_sorted_keys = list(dt_sorted.keys()) ls_vals = list(dt_sorted.values()) print(dt) correct_st = '' dt_len = len(dt) print(dt_len) for i in range(dt_len): correct_st = correct_st + ls_keys[i] + str(ls_vals[i]) print(correct_st)
@ramkrishnak6371
Күн бұрын
brother dont you think this code wont work when frequency is given in more than one digit like a10b5a2c7
@ritik.kumar15
4 ай бұрын
** Ques-1 : JAVA Solution using single loop ** import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; public class Test7 { public static void main(String[] args) { String compStr = "a3b2c5a1g9c2"; Map map = new HashMap(); for (int i = 0; i < compStr.length(); i+=2) { if (!map.containsKey(compStr.charAt(i))) { map.put(compStr.charAt(i), Character.getNumericValue(compStr.charAt(i+1))); } else { map.replace(compStr.charAt(i), map.get(compStr.charAt(i)) + Character.getNumericValue(compStr.charAt(i+1))); } } String correctStr = map.entrySet().stream().map(e -> e.getKey()+""+e.getValue()).collect(Collectors.joining("")); System.out.println(correctStr); } }
@ritik.kumar15
4 ай бұрын
** Ques -2 : JAVA Solution ** import java.util.Scanner; public class Test8 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); sc.close(); String binNum = ""; while (num != 1) { binNum += num % 2; num /= 2; } binNum += num; System.out.println(new StringBuilder(binNum).reverse().toString()); } }
@BhaveshKumar-dz8hq
7 ай бұрын
st = 'a3b2c4a4d6b5' l = list(st) d={} srr='' lt=[] l1=l[::2] l2 = set(l1) l3=list(l2) l3.sort() for i in l3: d[i]=l1.count(i) ll=list(d.items()) ln=len(ll)*2 for j in ll: for i in j: lt.append(i) for t in lt: srr=srr+str(t) print(srr) ##python code
@KomalSingh-qb3hx
9 ай бұрын
//program to convert binary number to decimal number import java.util.*; public class ibm4 { public static void main(String []args){ Scanner sc=new Scanner(System.in); String s=sc.nextLine(); StringBuffer sb=new StringBuffer(s); sb.reverse(); s=new String(sb); int n=Integer.parseInt(s); int rem=0; double dec=0; int i=0; while(n>0){ rem=n%10; dec=dec+rem*Math.pow(2,i); i++; n=n/10; } int ans=(int)dec; System.out.println(ans); } }
Пікірлер: 30