Category Archives: Uncategorized

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

Hello world!

Welcome to WordPress.com! This is your very first post. Click the Edit link to modify or delete it, or start a new post. If you like, use this post to tell readers why you started this blog and what you … Continue reading

Posted in Uncategorized | 1 Comment