Category Archives: Uncategorized

How to find an apartment and roommates

Find an interesting website to find apartment and roommates in the Bay Area and San Francisco: http://www.wanderful.io Wanderful is an online marketplace for apartments and roommates. By partnering with luxury apartments, they provide renters more options for apartments sharing besides … Continue reading

Posted in Apartment rental and roommate finding, Uncategorized | Leave a comment

How to design chatbot

Chatbot vs GUI Chatbot is an alternative User Interface besides website and app, providing service to users. The advantage of conversational: 1. Easy to understand and simple to use. 2. Provides permanent canonical record. 3. Feel far more human. The … Continue reading

Posted in Uncategorized | Leave a comment

Anagrams

Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. C++: 01 class Solution { 02 public: 03     vector<string> anagrams(vector<string> &strs) { 04         // Start typing your C/C++ … Continue reading

Posted in Uncategorized | Leave a comment

Connect the nodes in the same level

Given a binary tree, link all the nodes in the same level. C++: 01 void enList(Node** head, Node* cur) 02 { 03     if(cur==NULL) 04         return; 05     if(*head==NULL){ 06         cur->prv=cur; 07         cur->next=cur; … Continue reading

Posted in Uncategorized | Leave a comment

Word Search

Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically neighboring. The same letter cell may … Continue reading

Posted in Uncategorized | 3 Comments

Implement strstr() to find a substring in a string

Write C code to implement the strstr (Search for a substring) function. Do not use any system library such as strlen. C++: 01 int strstr(char* s, char* p) 02 { 03     int fast=0; 04     int slow=0; 05     int j=0; … Continue reading

Posted in String, Uncategorized | Leave a comment

Max of two numbers

Write a method which finds the maximum of two numbers. You should not use if-else or any other comparison operator. C++: 01 int signOfnumber(const int x) 02 { 03     return !((x>>31)&0x1); 04 } 05  06 int maxOftwo(int x, int y) 07 { 08    … Continue reading

Posted in Uncategorized | Leave a comment