@404BrainNotFound, It isn't asked anywhere but excited to see answers
Posts made by saiabhishke
Simple Python solution
We have a graph, and we need to create two sets of nodes. eg: [[1,3], [0,2], [1,3], [0,2]]
We can rewrite this in terms of adjacency list as :
Node => adacency list
0 => [1,3]
1 => [0,2]
2 => [1,3]
3 => [0,3]
Let the final set be first , second and initialized to empty.
Now, for each node in the graph, check following conditions :
- if node is first set, then all the adjacency nodes are to be added to second list. If any of the adjacent nodes are in first set then return false.
- if node is second set, then all the adjacency nodes are to be added to first list. If any of the adjacent nodes are in first set then return false.
- if node is not present neither in first nor second set, then check if any of the nodes in the adjacent list are in first or second.
a. If any of the node is in second list, then add node to first list and remaining nodes to second list.
b. If any of the node is in first list, then add node to first list and remaining nodes to first list.
If all nodes are processed then return true.
class Solution: def isBipartite(self, graph): """ :type graph: List[List[int]] :rtype: bool """ first =  second =  for index,i in enumerate(graph): f = False s = False # case 3 if index not in first and index not in second: for j in i : if j in first: f= True s= False break elif j in second: f= False s= True break if f: second.append(index) else: first.append(index) # case 1 if index in first : for j in i: if j in first : return False second.append(j) # case 2 if index in second : for j in i : if j in second: return False first.append(j) return True
e-Commerce Design and Implementation
If you have three months of time and you have to implement an e-Commerce website. What is your basic design? What are the functionalities you would implement?
Can you implement any new functionality that stands out from other e-commerce websites?