Open in app

Sign In

Write

Sign In

Abhinay Gupta
Abhinay Gupta

4 Followers

Home

About

3 days ago

SOLID Principles

Why Solid principles? ▪If Android developers design and implement their codes without using structured design principles such as SOLID principles, they will create long-lasting problems, and probability of success for an application will be decreased in future. ▪ Using SOLID principles in Android development could be helpful and effective to follow clean code…

Solid Principles

5 min read

SOLID Principles
SOLID Principles
Solid Principles

5 min read


May 5

Spiral Matrix

https://leetcode.com/problems/spiral-matrix/ Let inputMatrix be a matrix of numRows rows and numColscolumns. Look carefully at the image above. Instead of following numerical order, we’ll copy the outer edges of the array, in order. Then we’ll move on to the inner edges. These edges create the spiral. …

Leetcode

1 min read

Leetcode

1 min read


May 4

Difference Array

Corporate Flight Bookings Corporate Flight Bookings - LeetCode Can you solve this real interview question? Corporate Flight Bookings - There are n flights that are labeled from 1 to…leetcode.com So the idea is that every booking will be update to a range, and for range update, we have a special data structure Difference Array which could handle it in O(1) time. In a nutshell, a difference array is an seperated array that stores the difference of adjacent elements of…

Difference Array

1 min read

Difference Array

1 min read


May 3

Word break problem

Given a string s='abcde' and a dictionary of valid words valid_words=['a', 'ab', 'cd', 'cde', 'e'], return all possible ways to break down the string into only valid words (e.g. ['ab cd e', 'ab cde']). Leetcode Link We can decompose this problem by first identifying which valid words are also prefixes…

Word Break

2 min read

Word break problem
Word break problem
Word Break

2 min read


May 2

Sales Path

The car manufacturer Honda holds their distribution system in the form of a tree (not necessarily binary). The root is the company itself, and every node in the tree represents a car distributor that receives cars from the parent node and ships them to its children nodes. The leaf nodes…

Interview Questions

2 min read

Sales Path
Sales Path
Interview Questions

2 min read


May 2

Flatten a Dictionary

Given a dictionary dict, write a function flattenDictionary that returns a flattened version of it. Assume that values are either an integer, a string, or another dictionary. If a certain key is empty, it should be excluded from the output (see e in the example below). input: dict =…

Data Structures

1 min read

Data Structures

1 min read


Oct 11, 2022

LeetCode2096: Step-By-Step Directions From a Binary Tree Node to Another

Algorithm: Find the Strings from root to start and root to dest. And then remove the common prefix of both the strings. Replace each character of start string with ‘U’ . And concatinate the start string with the reversed dest string. /** * Definition for a binary tree node. *…

Leetcode

1 min read

Leetcode

1 min read


Jul 14, 2021

LRU Cache Implementation

class LRUCache { private Map<Integer, Node> map; final Node head = new Node(); final Node tail = new Node(); private int capacity; public LRUCache(int capacity) { this.map = new HashMap<>(capacity); this.capacity = capacity…

Lru

1 min read

Lru

1 min read


Jul 13, 2021

Implement HashMap in Java

to implement following functions in HashMap: put(), get(), remove(), size(),keySet(),containsKey() We will be using Arrays of LinkedList . Each linked List will represent a bucket. After hashing of keys, the key will be added to its corresponding bucket. Our Node will look like this . private class HMNode{…

Hashmap

3 min read

Hashmap

3 min read


Jul 11, 2021

Implementing Tries

class Trie { class TrieNode{ Map<Character,TrieNode> children = new HashMap<>(); boolean isLeaf; } private TrieNode root; /** Initialize your data structure here. */ public Trie() { root= new TrieNode(); } /** Inserts a word into the trie. */ public void insert(String word) { TrieNode node = root; for(char c : word.toCharArray()){ if(!node.children.containsKey(c)){ node.children.put(c,new TrieNode()); } node = node.children.get(c); } node.isLeaf= true; } /** Returns if the word is in the trie. */ public boolean search(String word) { TrieNode p = root; for(char c : word.toCharArray()) { if(!p.children.containsKey(c)) { return false; } p = p.children.get(c); } return p.isLeaf; } /** Returns if there is any word in the trie that starts with the given prefix. */ public boolean startsWith(String prefix) { TrieNode p = root; for(char c : prefix.toCharArray()) { if(!p.children.containsKey(c)) { return false; } p = p.children.get(c); } return true; } }

Trie

1 min read

Trie

1 min read

Abhinay Gupta

Abhinay Gupta

4 Followers

Software Developer at Make My Trip

Following
  • Vincent Tsen

    Vincent Tsen

  • Beck Moulton

    Beck Moulton

  • Arslan Ahmad

    Arslan Ahmad

  • Dan M.

    Dan M.

  • Amit Shekhar

    Amit Shekhar

See all (40)

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech

Teams