Skip to content

Instantly share code, notes, and snippets.

View chaudharisuresh997's full-sized avatar
🤓

Suresh Chaudhari chaudharisuresh997

🤓
View GitHub Profile
public class Solution {
public int divide(int A, int B) {
if(A==Integer.MIN_VALUE && B<0){
return Integer.MAX_VALUE;
}else if(A==Integer.MIN_VALUE && B>0){
return Integer.MIN_VALUE;
}
if(A==Integer.MAX_VALUE){
return Integer.MAX_VALUE;
}
@chaudharisuresh997
chaudharisuresh997 / Permutaion.java
Created December 26, 2019 10:55
Permutation is repeating list in output.
import java.util.ArrayList;
public class Solution{
public ArrayList<ArrayList<Integer>> permute(ArrayList<Integer> A) {
ArrayList<ArrayList<Integer>> big=new ArrayList<ArrayList<Integer>>();
permute(big,A,0);
return big;
}
@chaudharisuresh997
chaudharisuresh997 / git loose object error.txt
Created February 11, 2020 08:30
Git loose oebject error
https://stackoverflow.com/questions/4254389/git-corrupt-loose-object
Your best bet is probably to simply re-clone from the remote repo (ie. Github or other). Unfortunately you will lose any unpushed commits and stashed changes, however your working copy should remain intact.
First make a backup copy of your local files. Then do this from the root of your working tree:
rm -fr .git
git init
git remote add origin [your-git-remote-url]
git fetch
@chaudharisuresh997
chaudharisuresh997 / nestedmap.go
Created February 17, 2020 08:44
Nested Map golang tutorial
package main
import (
"fmt"
"encoding/json"
)
type ProjectAttributes struct{
ProjectId string
Attributes map[string]interface{}
}
@chaudharisuresh997
chaudharisuresh997 / gocodecoverage.sh
Last active March 18, 2020 11:44
Go Code coverge
gocov test ./... | gocov-xml > coverage.xml
https://github.com/AlekSi/gocov-xml
go get github.com/axw/gocov/gocov
go test workspace/... --coverprofile=coverage.txt
gocov convert coverage.txt > coverage.json
gocov-xml < coverage.json > coverage.xml 
#Go coverage
https://github.com/ory/go-acc
//https://www.interviewbit.com/problems/combination-sum/
public class Solution {
public ArrayList<ArrayList<Integer>> combinationSum(ArrayList<Integer> A, int B) {
ArrayList<ArrayList<Integer>> big=new ArrayList<ArrayList<Integer>>();
if(A.size()==0){
return big;
}
Collections.sort(A);
combination(big,0,A,B,new ArrayList<Integer>(),B);
Collections.sort(big,new Comparator<ArrayList<Integer>>(){
/*
take 1 2 3 4------1thousand two hundread thitry four
limit 10 lakh
*/
public class NumberToWord{
public String numLetters(char ch){
if(ch=='1'){
return "one";
@chaudharisuresh997
chaudharisuresh997 / Useful patterns and solutions for every topic in DS
Created June 6, 2020 03:51
Important and Useful links from all over the Leetcode
Important and Useful links from all over the Leetcode
Link:https://leetcode.com/discuss/general-discussion/665604/important-and-useful-links-from-all-over-the-leetcode
By deepika135
Most of the time I want to comeback to a particular post on Leetcode and so I have to bookmark different posts a lot of times. This has led to an increase to the number of my bookmarks a lot. Since there is no option to bookmark your favourite articles on Leetcode, I have been trying to compile a list of all Leetcode's important and useful links. Here is the list I have made till now. Posting it here so as to help the LC community as well. Do let me know the useful and important articles that I have missed. Will add them to this list. This way we all won't have to bookmark many posts on Leetcode and instead just bookmark this post alone.
Hope this helps -
I am trying to compile all the good posts on Leetcode. Comment down whichever I am missing and I will add all of them here -
DP for beginners by @wh0ami - https://leetcode.co
#Connect to pod
kubectl exec --stdin --tty shell-demo-pod -- /bin/bash
#for alpine image
kubectl exec --stdin --tty shell-demo-pod -- /bin/sh
#PING the kubernetes service
>nslookup "endpoint service ip"
#MOngo commands
#switch to collection
@chaudharisuresh997
chaudharisuresh997 / pythoncheat.py
Created January 14, 2021 10:27
Python3 cheatsheet
#Sort by the fields comparator
student_tuples = [
('john', 'A', 15),
('jane', 'B', 12),
('dave', 'B', 10),
]
sorted(student_tuples, key=lambda student: student[2]) # sort by age
[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]