Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. ExampleContinue Reading

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not contain duplicate triplets. Example: Given array nums = [-1, 0, 1, 2, -1, -4], A solution set is: [ [-1, 0, 1], [-1,Continue Reading

Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string “”. Example 1: Input: [“flower”,”flow”,”flight”] Output: “fl” Example 2: Input: [“dog”,”racecar”,”car”] Output: “” Explanation: There is no common prefix among the input strings. Note: All givenContinue Reading

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, two is written as II in Roman numeral, just two one’s added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is written as XXVII,Continue Reading

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, two is written as II in Roman numeral, just two one’s added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is written as XXVII,Continue Reading

Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. Note: You may not slant the containerContinue Reading

The C preprocessor (cpp) is the macro preprocessor for C and C++.   It is used for: 1)conditional compilation 2)inclusion of header files 3) macro expansion 4) special macros(__LINE__,__FILE__)   1) #if DEBUG    #elseif RELEASE    #elif    #endif 2) #include <stdio.h> And Also #pragma once replaces the oldContinue Reading

A proxy is a wrapper or agent object that is being called by the client to access the real serving object, this is achieved because both the proxy and the real object implement the same interface. Example C++ class IPerson { public: virtual void Drive() = 0; }; class PersonContinue Reading

#include <string> #include <iostream> #include <thread> using namespace std; // The function we want to execute on the new thread. void task1(string msg) { cout << “task1 says: ” << msg; } int main() { // Constructs the new thread and runs it. Does not block execution. thread t1(task1, “Hello”);Continue Reading