dee707
BAN USER
- 16of 20 votes
AnswersGiven two object arrays of "id,weight" (sorted by weight), merge them together and create a one single array. If the "id"s are same values should be merged. Final resulting array should be sorted by weight. Result should be O(nlogn) in time complexity.
- dee707 in Switzerland| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm
Java Code based on above discussion
import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
// Given a list of 4 billion integers,
// find an integer not in the list using 4MB of memory. (interview was in Java)
public class MissingIntFinder {
// 4 MB can accommodate -> 4*8*1024*1024 = 32*(2^20) = 2^25
// 32 bit integer can have possible -> 2 ^ 32 numbers
// so if we assume the Integer range is 32 bit and we'll do the scan in 2 stages
// (0 -> 16bit) -> (16 -> 32bit)
// Following is a result of 1 stage scan
public static void main(String[] args) {
List<Integer> data = Arrays.asList(0,1,5,3,4,5,12,2,16,21);
BitSet bitSet = new BitSet(2^16);
for (Integer val : data) {
bitSet.set(val);
}
// nextClearBit : Returns the index of the first bit that is set to false that occurs
// on or after the specified starting index.
int nextClearBit = bitSet.nextClearBit(0);
System.out.println(nextClearBit);
}
}
Here is a solution which is very similar to one provided here. But still this is a brute-force solution.
public class AnyDirectionWordFinder {
public static void main(String[] args) {
String[][] letters = new String[][]{
{"a", "b", "c", "d", "e", "f"},
{"z", "n", "a", "b", "c", "f"},
{"f", "g", "f", "a", "b", "c"},
};
System.out.println(letters.length); // << NOTE THAT THIS IS "3"
System.out.println(letters[0].length); // << NOTE THAT THIS IS "6"
System.out.println(isWordFound(letters, "fnz")); // true
System.out.println(isWordFound(letters, "gng")); // false
System.out.println(isWordFound(letters, "fbz")); // false
}
private static boolean isWordFound(String[][] letters, String word) {
for (int x=0; x<letters.length; x++) {
for (int y=0; y<letters[0].length; y++) {
boolean[][] visited = new boolean[letters.length][letters[0].length];
if (traverse(word, letters, visited, x, y)) {
return true;
}
}
}
return false;
}
private static boolean traverse(String wordToMatch, String[][] letters, boolean[][] visited, int x, int y) {
if (wordToMatch.length() == 0) {
return true;
}
if (x >= letters.length || y >= letters[0].length
|| x < 0 || y < 0) {
return false;
}
String firstLetter = wordToMatch.substring(0,1);
if (!visited[x][y] && letters[x][y].equals(firstLetter)) {
visited[x][y] = true;
String newWordToMatch = wordToMatch.substring(1);
return
traverse(newWordToMatch, letters, visited, x+1, y) ||
traverse(newWordToMatch, letters, visited, x-1, y) ||
traverse(newWordToMatch, letters, visited, x+1, y+1) ||
traverse(newWordToMatch, letters, visited, x-1, y-1) ||
traverse(newWordToMatch, letters, visited, x, y+1) ||
traverse(newWordToMatch, letters, visited, x, y-1) ||
traverse(newWordToMatch, letters, visited, x-1, y+1) ||
traverse(newWordToMatch, letters, visited, x+1, y-1);
}
return false;
}
}
Replelarolen76, Android test engineer at Alliance Global Servies
As a Public finance economist I am working at Liberal company . Here I will take a leadership role in the ...
RepSusanHonda, Analyst at A9
I meet with clients to negotiate terms and prices on sales agreements, draw up the contract, and ensure the documents ...
Repednaheeks, Android test engineer at Automated Traders Desk
I am Edna, a blogger . As an editor with a strong background in English and Hindi language. I enjoy writing ...
RepAsaDills, HR Executive Trainee at Cerner Corporation
I 'm Asa Dills, My role of the Public Housing Manager (PHM) is complex. the financial viability of the property ...
RepKatieKate, Developer at Amazon
Katie , a general laborer skilled in construction work, landscaping and trimming, and other commercial and residential tasks. Love to find ...
Repjennykyiler, Area Sales Manager at AMD
Jenny , an Assistant Secretary with a track record of employer satisfaction in performing various administrative tasks, and completing visual presentations ...
RepMistySangra, Developer Program Engineer at Alliance Global Servies
I am Misty , working as a Database Administrator with 4+ years of experience installing, maintaining, and upgrading various servers and ...
RepBeccaElyn, Accountant at ADP
Basic literacy is generally a requirement for order-filling positions, because order fillers need to be able to understand written lists ...
RepAlizaMaurice, Applications Developer at Absolute Softech Ltd
Aliza, a photojournalist with six years of experience capturing powerful images that tell stories. Have connections with a Vashikaran Specialist ...
Rephejalbbelans299, Animator at ABC TECH SUPPORT
Professional agile project manager with over 2 years of experience in various facets of project management. Implement agile management ideals ...
Repolliejshea, Android test engineer at ABC TECH SUPPORT
Hello I am an application engineer. I love my work very much. Nowadays I am doing some new experiments. Like ...
Replarrymeisterl71, Analyst at ABC TECH SUPPORT
Working as Food cooking machine tender at Adray it's almost 10 years . Here I Operate or tend cooking equipment ...
Repwilsontrent895, Android Engineer at Accenture
My name is WilsonTrent . I am working at A.J. August Fashion Wear as a Physician . Here I am helping ...
RepTomHolman, abc at A9
I am an expert Metal Refining Furnace Operator And Tender with at least 2 Years of experience, excellent covers all ...
RepPhyllisGreene, Developer Advocate at Autonomy Zantaz
Phyllis , a Communication Specialist adept at executing promotion strategies, serving as a spokesperson, developing new communication tools, and analyzing marketing ...
RepMiaDavis, abc at 8x8
I have excellent communication skills that allow me to effectively lead my team and convey my ideas to them so ...
Repsarahchannah745, Android Engineer at ASAPInfosystemsPvtLtd
Hello, I am an information records clerk.We are responsible for maintaining their company records in a complete and orderly ...
Repkentyoung319, Applications Developer at ABC TECH SUPPORT
I am KentYoung . I am working as an Orthotics technician at The Wiz . As an orthotic technician,I manufacture orthotic ...
RepManilaRoche, Animator at Abs india pvt. ltd.
Manila , an extensive executive assistant with experience of 4 years in the field of administrative functions, managing the office of ...
Repjanetjgonzales87, Android Engineer at 247quickbookshelp
Hello I am an internet developer. And I am very much sorry to travel and read some interesting books. Right ...
RepValerieRodri, Associate at Apache Design
I am a Medical equipment repairer in the Morehouse lab at the University of Wichita. I enjoy working with high-technology ...
Repnormadyen99, Android Engineer at ABC TECH SUPPORT
I am the Directory Assistance Operator responsible for assisting the callers by making calls, supplying phone numbers, advising the on-call ...
Repjuanitasfalbo45, Android Engineer at 247quickbookshelp
Hey, Juanita Falbo, and I am working as a Yoga instructor. And nowadays I am doing a new experiment on ...
Repmeerjahelesan, Backend Developer at Abs india pvt. ltd.
My name is FredHolli. I am working at Warner Brothers Studio Store as a Human resources clerk .I mostly spend ...
RepEstaaMoore, Accountant at A9
I am working as a cashier. I quickly and accurately counted drawers at the start and end of each shitt ...
Repjohnsantana9ytt9, Backend Developer at Accolite software
I am working as a Support service manager at Pro Star Garden Management . I had a different experience while working ...
RepJessicaMoss, Member Technical Staff at Bloomberg LP
Jessica , a technical writer with 5+ years of experience writing high-quality internal and user-facing support. As I love to write ...
RepBessieHicks, Area Sales Manager at Accolite software
Professional Aerobics instructor with over 2 years experience in this field . I am working at Wilson's Jewelers . I am ...
RepLaylaMoore, Analyst at ADP
I am a skilled content editor with 3 years of excellent service in the communications field. I developed, researched, and ...
Reppfisterruiz, Accountant at 247quickbookshelp
Door-to-door is a canvassing technique that is generally used for sales, marketing, advertising, evangelism or campaigning, in which I walk ...
Repdodramee56, Associate at Absolute Softech Ltd
As a Lift truck operator at Fayva for almost ten years I am working here . Here I met different people ...
Replisalisajmorgan74, Animator at 247quickbookshelp
Hey, I am LisaMorgan and I am a Staff manager.I had heard a lot about Vashikaran Specialist,now I ...
RepGladysHenley, Blockchain Developer at ASU
Gladys , a Staffing Consultant adept at managing the whole lifecycle of candidate recruitment, organizing job fairs, workshops, and webinars, and ...
RepJenniaLopez, Associate at Absolute Softech Ltd
Jennia , a hard-working Packer with a strong determination to finish all assignments in a timely manner. Replaces , operates and maintains ...
RepCamilaHill, Accountant at ADP
I am a performance-driven leader providing high-level administrative and operational support, coordinating schedules, preparing travel and documents, and exploring Surah ...
Reppetersmith36788, Animator at ABC TECH SUPPORT
I am working at Eden Lawn Service as a Bridge and lock tender . Here I manage all the things like ...
Repbrianlwarren596, Android Engineer at 247quickbookshelp
Hey my name is BrainWarren and I am working as an Interpreter.my main work is Interpreters and translators convert ...
RepSaanviJones, abc at 8x8
I am working as an office worker in a softage company. I am responsible for an office assistant position in ...
RepHaleyTorres, abc at A9
I am an enterprising Corporate Accountant proficient in generally accepted accounting principles including use of the latest industry standard software ...
RepSerenaWilliams, Android test engineer at ASAPInfosystemsPvtLtd
Serena , a Building Consultant engages myself in ongoing communication with clients until the project is completed and collects necessary data ...
Repggroverwmiller, Android Engineer at 247quickbookshelp
Hello I am a Budget officer with 5 years of experience. The Budget Officer implements budgeting and financial record keeping ...
Repericsumm059, Backend Developer at ASU
My name is EricSummey . I am working as a Sound engineering technician at Foreman & Clark . as a sound technician it ...
RepJulianMiller, abc at ABC TECH SUPPORT
I am a professional auditing assistant with extensive experience in handling administrative duties and executive responsibilities associated with both internal ...
RepPeterRox, Java Developer at Cleartrip.com
I am Peter, a punctual, problem-solving, and communicative individual who possesses administration, finance, sales, computer skills and experience. I enjoy ...
Repdeckdella34, Applications Developer at Abs india pvt. ltd.
I am working as a Vascular sonographer at Food Barn . Here I handle many patients . Vascular sonographers, also called vascular ...
RepYuvaanBrown, abc at AMD
I am working as an art director in a lomni company. I have expert knowledge of adobe creative suite in ...
Repvickidsmithv, Android Engineer at 247quickbookshelp
Hello, I am a Managing editor. I have completed my studies from New York. Apart from this, whenever I am ...
RepJeremyBrett, Consultant at Capgemini
Jeremy , a Business Administrator with more than 4 years experience helping companies from various industries plan, organize and control specific ...
a DP solution where it coputes results in O(nm) and BigOmega(nm). Using Java
- dee707 October 18, 2016