Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.ossez.toolkits.codebank.common.model.request;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.io.Serializable;
import java.util.Objects;


/**
Expand Down Expand Up @@ -79,4 +83,20 @@ public String getCreated_at() {
public void setCreated_at(String created_at) {
this.created_at = created_at;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;

if (o == null || getClass() != o.getClass()) return false;

TopicRequest that = (TopicRequest) o;

return new EqualsBuilder().append(title, that.title).append(topic_id, that.topic_id).append(raw, that.raw).append(category, that.category).append(target_recipients, that.target_recipients).append(archetype, that.archetype).append(created_at, that.created_at).isEquals();
}

@Override
public int hashCode() {
return new HashCodeBuilder(17, 37).append(title).append(topic_id).append(raw).append(category).append(target_recipients).append(archetype).append(created_at).toHashCode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.ossez.toolkits.codebank.tests;

import com.google.api.gbase.client.NumberUnit;
import com.ossez.toolkits.codebank.common.model.request.TopicRequest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;


/**
* This is the test file for something like to quick run.
* Once test finished, we need to move codes to different name, just like when we were student we like to eraser after using.
*
* @author YuCheng
*/
public class BlackboardTest {
private final static Logger logger = LoggerFactory.getLogger(BlackboardTest.class);

private static List<Integer> loopList = new ArrayList<>();

/**
* Main Test to Run
*/
@Test
public void testMain() {
logger.debug("TREE TEST");

TopicRequest topicRequest = new TopicRequest();
// topicRequest.setTopic_id(11);
logger.debug("HashCode 1 - {}", topicRequest.hashCode());

logger.debug("HashCode AaAaAa - {}", "AaAaAa".hashCode());
logger.debug("HashCode BBAaBB - {}", "BBAaBB".hashCode());

// if((1/2) && false) {
//
// }

// topicRequest = new TopicRequest();
logger.debug("HashCode 2 - {}", topicRequest.hashCode());

String data = "{1,2,3,4,5,#,6,#,#,7,8,#,#}";

this.subLogic(data);
}


/**
* @param data
*/
private void subLogic(String data) {
logger.debug("Print Val - [{}]", data);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;

/**
* <p>
Expand All @@ -17,43 +19,62 @@
* "https://leetcode.com/problems/first-unique-character-in-a-string/">https://leetcode.com/problems/first-unique-character-in-a-string/</a>
* </ul>
* </p>
*
* @author YuCheng
*
* @author YuCheng
*/
public class LeetCode0387FirstUniqueCharacterTest {

private final static Logger logger = LoggerFactory.getLogger(LeetCode0387FirstUniqueCharacterTest.class);
private final static Logger logger = LoggerFactory.getLogger(LeetCode0387FirstUniqueCharacterTest.class);

/**
*
*/
@Test
public void testMain() {
logger.debug("BEGIN");
String data = "lovelycomossez";

System.out.println(firstUniqChar(data));

}

/**
*
*/
@Test
public void testMain() {
logger.debug("BEGIN");
String data = "leetcode";
/**
* Deserialize from array to tree
*
* @param data
* @return
*/
private int firstUniqChar(String data) {
// NULL CHECK
if (data.equals("")) {
return -1;
}

System.out.println(firstUniqChar(data));
int retVal = -1;
LinkedHashMap<Character, String> retMap = new LinkedHashMap<Character, String>();
char[] chStr = data.toCharArray();

}

/**
* Deserialize from array to tree
*
* @param data
* @return
*/
private int firstUniqChar(String data) {
// NULL CHECK
if (data.equals("")) {
return -1;
}
for (int i = 0; i < chStr.length; i++) {
if (retMap.get(chStr[i]) != null) {
retMap.put(chStr[i], retMap.get(chStr[i]) + "#" + String.valueOf(i));
} else {
retMap.put(chStr[i], String.valueOf(i));
}
}

for (Map.Entry me : retMap.entrySet()) {
String val = "" + me.getValue();
if (!val.contains("#")) {
retVal = Integer.valueOf(val);
break;
}
}

return 0;

}
return retVal;

}


}