title: Getting results in O(1) : Java
body: <p>I have java interface with</p>
  <pre><code>public interface Emp {
             void addEmp(int empId, String dept);
  
             void updateEmp(int empId, String dept);
  
             List&lt;EmpDTO&gt; getEmpByDept(String dept);
  
  }
  </code></pre>
  <p>Here there is no database connection and we are storing emp data in some java collection</p>
  <p>How can I implement all the above three method with the help of collection and with all of the three having time complexity O(1)</p>
  <p>Any help will be appreciated</p>