Skip to content

Instantly share code, notes, and snippets.

View skrauchenia's full-sized avatar
💭
I may be slow to respond.

Sergey Krauchenia skrauchenia

💭
I may be slow to respond.
  • Fiverun Inc
  • United Kingdom
View GitHub Profile
def func(arr: Array[Int],
leftSum: Int = 0, rightSum: Int = 0,
leftInx: Int = -1, rightIdx: Int = -1): Int = {
if (leftInx > rightIdx) {
if (leftSum == rightSum) leftInx else -1
} else {
func(arr.slice(leftInx, rightIdx), arr.head + leftSum, arr.last + rightSum, leftInx + 1, rightIdx - 1)
}
}
// your version
@RequestMapping(value="/addNewTag", method=RequestMethod.POST, produces = "application/json")
@ResponseBody
public Map<String, Integer> addNewTag(@RequestBody Map<String, String> requestMap, HttpServletResponse response) throws IOException {
if (addTagOnRuntime(requestMap.get("tagName"))) {
return Collections.singletonMap("statusCode", HttpServletResponse.SC_OK);
} else {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return null;