Kapil Patel

Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

Input: nums = [1,2,3,1]
Output: true
Input: nums = [1,2,3,4]
Output: false
Input: nums = [4,4,4,2,3,4,5,6,6]
Output: true

My first solution (Not very good):

class Solution {
public boolean containsDuplicate(int[] nums) {
int length = nums.length;
for(int i=0; i<length; i++){
for(int j=i+1; j<length;j++)
{
if(nums[i]==nums[j])
{
return true;
}
}
}
return false;

}
}

Second solution- I tried using Java Hashmap which got accepted but I am not happy, why to use hashmap while I only need to store 1 data point

class Solution {
public boolean containsDuplicate(int[] nums) {
int length = nums.length;
HashMap<Integer, Integer> collection = new HashMap<>();
for(int i=0; i<length; i++){


if(collection.containsKey(nums[i])){
return true;
}else{
collection.put(nums[i],0);
}
}
return false;

}
}

--

--

Given a string, write a c function to check if it is palindrome or not.

A string is said to be palindrome if reverse of the string is same as string. For example, “kppk” is palindrome, but “kppa” is not palindrome.

CPP

#include<bits/stdc++.h>
using namespace std;
bool isPalindrome(string str)
{
int left = 0;
int right = str.length()-1;
while(str[left] == str[right] )
{
if(left == right-1 || left == right)
{
return true;
}
left++;
right--;
}
return false;
}

--

--

This is a copy paste question from Daily Bite email.

This question is asked by Google. Given a string, reverse all of its characters and return the resulting string.

Ex: Given the following strings…

“Cat”, return “taC”
“The Daily Byte”, return "etyB yliaD ehT”
“civic”, return “civic”

Solution using C#

using System;public class Test
{
public static void Main()
{
// your code goes here
string name = "Kapil";

System.Console.WriteLine(name);
int length = name.Length;
for(int i=length-1; i>=0; i--)
{
System.Console.Write(name[i]);
}
}
}

Disclaimer: Copied without permission from The Daily Bite email.

thedailybyte.dev

My self Kapil Patel a software engineer with 8 years of experience. I am trying to solve this with whatever knowledge I have, also I will be improving my solution as I find better solutions from fellow engineers!

--

--

Must have for a back-end engineer

This is a partial list, I will keep updating it as I find

.NET background

C#
.Net Core
Web Api
Unit Test Framework (nUnit/xUnit)
SQL Server, CRUD operation
Cloud (Azure/Openshift/AWS/other cloud tech), if have hosting experience in one of these that’s fine
Microservices :- Good to have
Apache Kafka/Rabbit MQ or other message broker :- Good to have
DevOps (Azure DevOps/Jenkins/Bamboo/Octopus/any other CI/CD tools) and Unit-test integration in CI/CD pipeline :- Good to have

--

--