Bloomberg interview question

Please check above

Interview Answers

Anonymous

30 Jan 2017

package String; import java.util.Scanner; public class RemoveArbitrySpace { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //Scanner scan = new Scanner (System.in); String mystring = " s mallem "; char previous = ' '; String s2; for(int i=0; i

13

Anonymous

30 Jan 2017

SELECT * FROM `test` WHERE LENGTH(SUBSTR(`salary`,INSTR(`salary`,"."))) = 5 INSTR(yourFloatNumber, Dot) => returns the position of dot in the float number SUBSTR(yourFloatNumber, positionOfDot) => return the substring : begining from the position of DOT till the end of float length (subStringExtracted) => count number of caracter including the DOT.

4

Anonymous

5 Apr 2017

public static String trim(String s) { char first = s.charAt(0); char last = s.charAt(s.length() - 1); int countStartWhitespace = 0; int countEndWhitespace = 0; while ((first == ' ' || last == ' ') && (countStartWhitespace < s.length() / 2) && (countEndWhitespace < s.length() / 2)) { if(first == ' ') { countStartWhitespace++; first = s.charAt(countStartWhitespace); } if(last == ' ') { countEndWhitespace++; last = s.charAt(s.length() - 1 - countEndWhitespace); } } return s.substring(countStartWhitespace, s.length() - countEndWhitespace); }

1

Anonymous

2 June 2018

'remove arbitrary spaces '.replace(/\s+/g, ' ').trim();

Anonymous

30 Jan 2017

DBMS vs File System File System is challenging: * Losing files * Finding a file * files are located in different physical computers * should do the Backup regularly and with short time So File system works only if you keep your self very organized . On the other hand, DBMS allows to : * Store retrieve data with easy way * manage concurrency * Security rules to determine access levels for users * backup and recovery * Data description : * Integrity : set of rules to determine that the data didn't changed . Example ; colum as varchar is varchar * Define audit and logging * Define indexing * Define trigger and stored procedure

Anonymous

24 Mar 2017

Answer for "Remove space from the string" import java.util.Queue; //Remove arbitrary string //Input : The sky is blue . //Output: The sky is blue. public class removeExtraSpaceString { public static void main(String args[]){ String s =" The sky is blue . "; removeString(s); } public static void removeString(String s){ System.out.println(s); String ss = s.trim(); System.out.println(ss); StringBuilder sb = new StringBuilder(); Queue q =null; int j=0, i=0; int n=ss.length(); while(j